3 #ifndef AST_FILE_IO_HEADER
4 #define AST_FILE_IO_HEADER
5 #include "AstSpecificDataManagingClass.h"
14 #define REGISTER_ATTRIBUTE_FOR_FILE_IO(CLASS_TO_BE_REGISTERED ) AST_FILE_IO::registerAttribute<CLASS_TO_BE_REGISTERED> ( ) ;
16 typedef AstSpecificDataManagingClass
AstData;
31 ROSE_ASSERT(node != NULL);
44 enum { totalNumberOfIRNodes = 783};
45 static unsigned long binarySearch(
unsigned long globalIndex,
int start = 0 ,
int end = totalNumberOfIRNodes );
46 static unsigned long linearSearch(
unsigned long globalIndex ) ;
49 static unsigned long listOfMemoryPoolSizes [ totalNumberOfIRNodes + 1] ;
51 static SgNode* getPointerFromGlobalIndex (
unsigned long globalIndex );
60 static unsigned long getSizeOfMemoryPool (
const int position );
61 static unsigned long getSizeOfMemoryPoolUpToAst (
AstData* astInPool,
const int position );
62 static unsigned long getAccumulatedPoolSizeOfNewAst(
const int position);
63 static unsigned long getAccumulatedPoolSizeOfAst(
AstData* astInPool,
const int position);
64 static unsigned long getPoolSizeOfNewAst(
const int sgVariant);
65 static unsigned long getTotalNumberOfNodesOfAstInMemoryPool ( );
66 static unsigned long getTotalNumberOfNodesOfNewAst ();
67 static bool areFreepointersContainingGlobalIndices ( );
70 static unsigned long getGlobalIndexFromSgClassPointer (
SgNode* pointer ) ;
71 static SgNode* getSgClassPointerFromGlobalIndex (
unsigned long globalIndex) ;
72 static void compressAstInMemoryPool() ;
73 static void resetValidAstAfterWriting();
74 static void clearAllMemoryPools ( );
75 static void deleteStaticData( );
76 static void deleteStoredAsts( );
77 static void setStaticDataOfAst(
AstData* astInPool);
78 static int getNumberOfAsts ();
79 static void addNewAst (
AstData* newAst);
80 static void extendMemoryPoolsForRebuildingAST ( );
81 static void writeASTToStream ( std::ostream& out );
82 static void writeASTToFile ( std::string fileName );
83 static std::string writeASTToString ();
84 static SgProject* readASTFromStream ( std::istream&
in );
85 static SgProject* readASTFromFile (std::string fileName );
86 static SgProject* readASTFromString (
const std::string& s );
87 static void printFileMaps () ;
88 static void printListOfPoolSizes () ;
89 static void printListOfPoolSizesOfAst (
int index) ;
90 static AstData* getAst (
int index) ;
94 static void registerAttribute ( );
95 static const std::map <std::string, CONSTRUCTOR>& getRegisteredAttributes ();
101 static void display(
const std::string & label);
105 template <
class TYPE>
109 std::string
name = TYPE().attribute_class_name();
116 inline const std::map <std::string, AST_FILE_IO::CONSTRUCTOR>&
121 #endif //AST_FILE_IO_HEADER