utility_functions.h

Go to the documentation of this file.
00001 // utility_functions.h -- header file for the ROSE Optimizing Preprocessor
00002 
00003 #ifndef UTILITY_FUNCTIONS_H
00004 #define UTILITY_FUNCTIONS_H
00005 
00006 #include "Cxx_Grammar.h"
00007 class UnparseDelegate;
00008 
00009 #define BACKEND_VERBOSE_LEVEL 2
00010 
00011 // DQ (11/1/2009): replaced "version()" with separate "version_number()" and "version_message()" functions.
00012 // returns a string containing the current version message (includes the version number).
00013 std::string version_message();
00014 
00015 // DQ (11/1/2009): replaced "version()" with separate "version_number()" and "version_message()" functions.
00016 // returns a string containing the current version number
00017 std::string version_number();
00018 
00020 std::string rose_scm_version_id();
00021 
00023 time_t rose_scm_version_date();
00024 
00025 // Simple interface for ROSE (error codes are in SgProject.frontendErrorCode(), backendErrorCode() )
00026 // tps : Need to make this function (DLL) public 
00027 ROSE_DLL_API SgProject* frontend ( int argc, char** argv, bool frontendConstantFolding = false );
00028 ROSE_DLL_API SgProject* frontend ( const std::vector<std::string>& argv, bool frontendConstantFolding = false );
00029 
00030 // This builds a shell of a frontend SgProject with associated SgFile objects (but with empty 
00031 // SgGlobal objects) supporting only commandline processing and requiring the frontend to be 
00032 // called explicitly for each SgFile object.  See tutorial/selectedFileTranslation.C for example.
00033 SgProject* frontendShell ( int argc, char** argv);
00034 SgProject* frontendShell ( const std::vector<std::string>& argv);
00035 
00036 // DQ (3/18/2006): Modified backend function interface to permit handling of user specified
00037 // objects to control the formatting of code generation and the use of alternative code generation
00038 // techniques (e.g. copy-based code generation).
00039 // int backend ( SgProject* project );
00040 ROSE_DLL_API int backend ( SgProject* project, UnparseFormatHelp *unparseFormatHelp = NULL, UnparseDelegate* unparseDelagate = NULL );
00041 
00042 // DQ (8/24/2009): This backend calls the backend compiler using the original input source file list.
00043 // This is useful as a test code for testing ROSE for use on projects that target Compass or any
00044 // other analysis only tool using ROSE. Called in tests/testAnalysis.C for example.
00045 int backendCompilesUsingOriginalInputFile ( SgProject* project, bool compile_with_USE_ROSE_macro = false );
00046 
00047 // DQ (2/6/2010): This backend forces all code to be generated but still uses the beakend vendor 
00048 // compiler to compile the original code.  This is a step between backendUsingOriginalInputFile(),
00049 // which does not generate code; and backend() which generated code and compiles it.  The use of
00050 // this backend permits an intermediate test of robustness where the code that we generate might
00051 // be generated incorrectly (usually with missing name qualification as required for a specific 
00052 // backend (vendor) compiler).
00053 int backendGeneratesSourceCodeButCompilesUsingOriginalInputFile ( SgProject* project );
00054 
00055 //QY: new back end that performs only source-to-source translations 
00056 // of the original file. Furthermore, statements are copied from 
00057 // the original file if they are not changed
00058 int copy_backend( SgProject* project, UnparseFormatHelp *unparseFormatHelp = NULL );
00059 
00060 // int globalBackendErrorCode  = 0;
00061 // int backend ( const SgProject & project, int & errorCode = globalBackendErrorCode);
00062 // SgProject & frontend ( int argc, char * argv[] );
00063 
00064 void generatePDF ( const SgProject & project );
00065 void generateDOT ( const SgProject & project, std::string filenamePostfix = "" );
00066 
00067 // DQ (9/1/2008): Added function to generate the compete AST when specificed with multiple files 
00068 // on the command line.  This is the older default behavior of generateDOT (from last year, or so).
00069 void generateDOT_withIncludes   ( const SgProject & project, std::string filenamePostfix = "" );
00070 void generateDOTforMultipleFile ( const SgProject & project, std::string filenamePostfix = "" );
00071 
00072 // DQ (6/14/2007): Support for whole AST graphs output with attributes (types, symbols, all edges, etc.)
00073 // We define a default value for the maximum graph size (number of nodes).
00074 void generateAstGraph ( const SgProject* project, int maxSize = 2000, std::string filenameSuffix = "" );
00075 // void generateAstGraph ( const SgProject* project, int maxSize, std::string filenameSuffix = "", CustomMemoryPoolDOTGeneration::s_Filter_Flags* filter_flags = NULL)
00076 
00077 // output of EDG AST (useful for debugging connection to SAGE)
00078 //void pdfPrintAbstractSyntaxTreeEDG ( SgFile *file );
00079 // void generatePDFofEDG ( const SgProject & project );
00080 
00081 //#include "rose.h"
00082 //#include "../midend/astProcessing/DOTGeneration.h"
00083 //#include "roseInternal.h"
00084 //#include "../midend/astProcessing/AstDotGeneration.h"
00085 //using namespace AstDOTGenerationExtended_Defaults;
00086 //#include "../midend/astProcessing/AstDOTGeneration.h"
00087 #include "AstDOTGeneration.h"
00088 
00089 template <typename ExtraNodeInfo_t = AstDOTGenerationExtended_Defaults::DefaultExtraNodeInfo, typename ExtraNodeOptions_t = AstDOTGenerationExtended_Defaults::DefaultExtraNodeOptions, typename ExtraEdgeInfo_t = AstDOTGenerationExtended_Defaults::DefaultExtraEdgeInfo, typename ExtraEdgeOptions_t = AstDOTGenerationExtended_Defaults::DefaultExtraEdgeOptions>
00090 struct generateDOTExtended ;
00091 //void
00092 //generateDOTExtended ( const SgProject & project, std::string filenamePostfix = "", ExtraNodeInfo_t eni = AstDOTGenerationExtended_Defaults::DefaultExtraNodeInfo(), ExtraNodeOptions_t eno = AstDOTGenerationExtended_Defaults::DefaultExtraNodeOptions(), ExtraEdgeInfo_t eei = AstDOTGenerationExtended_Defaults::DefaultExtraEdgeInfo(), ExtraEdgeOptions_t eeo = AstDOTGenerationExtended_Defaults::DefaultExtraEdgeOptions() );
00093 
00094 template <typename ExtraNodeInfo_t = AstDOTGenerationExtended_Defaults::DefaultExtraNodeInfo, typename ExtraNodeOptions_t = AstDOTGenerationExtended_Defaults::DefaultExtraNodeOptions, typename ExtraEdgeInfo_t = AstDOTGenerationExtended_Defaults::DefaultExtraEdgeInfo, typename ExtraEdgeOptions_t = AstDOTGenerationExtended_Defaults::DefaultExtraEdgeOptions>
00095 struct generateDOTExtended_withIncludes ;
00096 
00097 template <typename ExtraNodeInfo_t = AstDOTGenerationExtended_Defaults::DefaultExtraNodeInfo, typename ExtraNodeOptions_t = AstDOTGenerationExtended_Defaults::DefaultExtraNodeOptions, typename ExtraEdgeInfo_t = AstDOTGenerationExtended_Defaults::DefaultExtraEdgeInfo, typename ExtraEdgeOptions_t = AstDOTGenerationExtended_Defaults::DefaultExtraEdgeOptions>
00098 struct generateDOTExtendedforMultipleFile ;
00099 
00100 namespace ROSE
00101    {
00102   // This class serves as a catch all location for functions of general use within ROSE
00103   // we have added variables that are set using command line parameters to avoid the use of
00104   // global variables.  
00105 
00106        // DQ (8/10/2004): This was moved to the SgFile a long time ago and should not be used any more)
00107        // DQ (8/11/2004): Need to put this back so that there is a global concept of verbosity for all of ROSE.
00108        // static int roseVerboseLevel;
00109 
00110        // These functions trim the header files from the unparsed output.
00111        // static int isCutStart ( SgStatement *st );
00112        // static int isCutEnd ( SgStatement *st );
00113        // void ROSE_Unparse ( SgFile *f , std::ostream *of );
00114 
00115        // This function helps isolate the details of the UNIX strcmp function
00116        // static int isSameName ( const std::string& s1, const std::string& s2 );
00117           int containsString ( const std::string& masterString, const std::string& targetString );
00118 
00119         // DQ (9/5/2008): Try to remove these functions...
00120           std::string getFileNameByTraversalBackToFileNode ( const SgNode* astNode );
00121        // std::string getFileName ( const SgFile* file );
00122 
00123        // DQ (5/25/2005): Removed from ROSE class (since they are redundant with other uses)
00124           std::string getFileName     ( SgLocatedNode* locatedNodePointer ) ROSE_DEPRECATED_FUNCTION;
00125           int   getLineNumber   ( SgLocatedNode* locatedNodePointer ) ROSE_DEPRECATED_FUNCTION;
00126           int   getColumnNumber ( SgLocatedNode* locatedNodePointer ) ROSE_DEPRECATED_FUNCTION;
00127           bool  isPartOfTransformation( SgLocatedNode* locatedNodePointer ) ROSE_DEPRECATED_FUNCTION;
00128 
00129           std::string getWorkingDirectory (); 
00130           std::string getSourceDirectory  ( std::string fileNameWithPath ); 
00131 
00132           std::string getFileNameWithoutPath ( SgStatement* statementPointer );
00133           std::string stripPathFromFileName ( const std::string& fileNameWithPath ); 
00134 
00135           std::string getPathFromFileName   ( std::string fileNameWithPath ); 
00136 
00137        // DQ (9/8/2008): This is removed since it is redundant with the version in StringUtility.
00138        // std::string stripFileSuffixFromFileName ( const std::string& fileNameWithSuffix ); //! get the name without the ".C"
00139 
00140        // std::string getPragmaString ( SgStatement  *stmt );
00141        // std::string getPragmaString ( SgExpression *expr );
00142 
00143        // SgPragma* getPragma ( SgExpression *expr );
00144        // SgPragma* getPragma ( SgStatement  *stmt );
00145        // SgPragma* getPragma ( SgBinaryOp   *binaryOperator );
00146 
00147        // std::string identifyVariant ( int Code );
00148 
00149           SgName concatenate ( const SgName & X, const SgName & Y );
00150 
00151           void usage (int status);
00152 
00153           void filterInputFile ( const std::string inputFileName, const std::string outputFileName );
00154 
00156           SgStatement* getPreviousStatement ( SgStatement *targetStatement );
00157           SgStatement* getNextStatement     ( SgStatement *targetStatement );
00158 
00159    };
00160 
00161 #endif // ifndef UTILITY_FUNCTIONS_H
00162 
00163 
00164 
00165 
00166 
00167 
00168 

Generated on Sat May 19 00:53:07 2012 for ROSE by  doxygen 1.4.7