attach_all_info.h

Go to the documentation of this file.
00001 #ifndef _ATTACH_ALL_INFO_H_
00002 #define _ATTACH_ALL_INFO_H_
00003 
00004 #if 0
00005 struct wrap_data_used_by_AttachPreprocessingInfoTreeTrav_t
00006    {
00007      SgLocatedNode *previousLocNodePtr;
00008 #if 0
00009   // DQ (11/30/2008): Moved currentListOfAttributes to inherited attribute
00010      ROSEAttributesList *currentListOfAttributes;
00011      int sizeOfCurrentListOfAttributes;
00012 #endif
00013   // wrap_data_used_by_AttachPreprocessingInfoTreeTrav_t(SgLocatedNode* node=NULL, ROSEAttributesList* preprocInfo=NULL, int len=0);
00014      wrap_data_used_by_AttachPreprocessingInfoTreeTrav_t(SgLocatedNode* node=NULL);
00015    };
00016 #else
00017 // DQ (12/3/2008): This is the data that we have to save (even though the currentListOfAttributes has been moved to the inherited attribute)
00018 struct wrap_data_used_by_AttachPreprocessingInfoTreeTrav_t
00019    {
00020      SgLocatedNode *previousLocNodePtr;
00021      ROSEAttributesList *currentListOfAttributes;
00022      int sizeOfCurrentListOfAttributes;
00023      wrap_data_used_by_AttachPreprocessingInfoTreeTrav_t(SgLocatedNode* node=NULL, ROSEAttributesList* preprocInfo=NULL, int len=0);
00024    };
00025 #endif
00026 
00027 class AttachAllPreprocessingInfoTreeTrav : public AttachPreprocessingInfoTreeTrav
00028    {
00029      private:
00030           std::string src_file_name;
00031           SgFile * sage_file;
00032 
00033        /* map: key = filename, value = a wrapper for the data used in AttachPreprocessingInfoTreeTrav. */
00034           std::map<int, wrap_data_used_by_AttachPreprocessingInfoTreeTrav_t> map_of_all_attributes;
00035 
00036        /* map: key = filename, value = the first node in AST from the file (could be NULL) */
00037        /* std::map<std::string, SgNode*> map_of_first_node; */
00038        /* I need to keep the order for each file when it is discovered from AST */
00039           int nFiles;                   /* total number of files involved */
00040           std::map<int, int> map_of_file_order;
00041 
00042           std::vector<SgNode*> array_of_first_nodes;
00043 
00044        // This is hepful in limiting the amount of data saved and files processed
00045        // within the handling of a large application that include system header files.
00046        // Basically we want to avoid processing comments in system header files 
00047        // because they are not relevant.
00048        // Holds paths to exclude when getting all commments and directives
00049           std::vector<std::string> pathsToExclude;
00050           bool lookForExcludePaths;
00051 
00052        // Holds paths to include when getting all comments and directives
00053           std::vector<std::string> pathsToInclude;
00054           bool lookForIncludePaths;
00055 
00056        /* set the first node for the file (may resize the
00057           array_of_first_nodes); return false means the first node for the
00058           file has already existed and keep the previous first node. */
00059           bool add_first_node_for_file(const int, SgNode* n, int pos);
00060 
00061        /* it returns the first node after file "fn"; return <NULL,
00062           anything> iff no node in the whole array_of_first_nodes for
00063           attaching preprocessing info; "hintfororder" is the number of
00064           handled files before file "fn". */
00065           std::pair<SgNode*, PreprocessingInfo::RelativePositionType> get_first_node_for_file(const int fn, int hintfororder);
00066 
00067      public:
00068           AttachAllPreprocessingInfoTreeTrav(SgFile * sagep);
00069 
00070        /* Pi: To make the way for attaching preproc info the same as
00071           before, we basically call the same functions in
00072           AttachPreprocessingInfoTreeTrav, although we need to set the data
00073           used by them before calling them, and update the data after they
00074           use it. */
00075           AttachPreprocessingInfoTreeTraversalInheritedAttrribute evaluateInheritedAttribute( SgNode *n,        AttachPreprocessingInfoTreeTraversalInheritedAttrribute inh);
00076           AttachPreprocessingInfoTreeTraversalSynthesizedAttribute evaluateSynthesizedAttribute( SgNode *n,AttachPreprocessingInfoTreeTraversalInheritedAttrribute inh, SubTreeSynthesizedAttributes st);
00077 
00078        /* to handle those files which contain no IR nodes. */
00079      private:
00080           std::istream & dependancies;  /* use cin for now, better to run ROSE internally to get the list. TODO. */
00081      public:
00082        /* attach preproc info from files containing no IR nodes: assume the
00083           order of the list of dependency files are in the correct order,
00084           attach such preproc info to the first node from the files after
00085           the current file. TODO: still have a problem if no files after
00086           the current file. */
00087       //  bool attach_left_info();
00088 
00089        // DQ (10/27/2007): Added display function to output information gather durring the collection of 
00090        // comments and CPP directives across all files.
00091           void display(const std::string & label) const;
00092    };
00093 
00094 #if 0
00095 // DQ (10/27/2007): This is not used!
00096 
00097 void attachAllPreprocessingInfo1(SgProject* sagep, const char * dep); /* dep is the file containing a list of dependencies. */
00098 /* Alg (Too slow): (1) use appropriate shell commands to get a list of
00099    dependencies (in a certain format) (could be automated based on the
00100    command line options stored in sagep); (2) suppose n dependencies:
00101    traverse the whole AST n times, each time set current file name in
00102    the SgFile node to a different dependency before traversal (a hack
00103    based on evaluateInheritedAttribute(...) in class
00104    AttachPreprocessingInfoTreeTrav */
00105 
00106 // DQ (4/19/2006): This is now placed into the attachPreprocessingInfo(SgFile*) function!
00107 // void attachAllPreprocessingInfo(SgFile* sagep);
00108 #endif
00109 
00110 #endif /* _ATTACH_ALL_INFO_H_ */

Generated on Wed May 16 06:17:53 2012 for ROSE by  doxygen 1.4.7