1 #ifndef __ROSEAttributesList_H__
2 #define __ROSEAttributesList_H__
11 #include "general_token_defs.h"
56 #ifdef ROSE_DEBIAN_OS_VENDOR
57 #if (ROSE_BOOST_VERSION == 105400)
58 #define ROSE_SKIP_COMPILATION_OF_WAVE
66 #define ROSE_SKIP_COMPILATION_OF_WAVE
72 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
74 #if (!defined(_MSC_VER) || (_MSC_VER > 1600))
75 #include <boost/preprocessor/iteration/iterate.hpp>
77 #include <boost/wave.hpp>
79 #include <boost/wave/cpplexer/cpp_lex_token.hpp>
80 #include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
85 #pragma message ("Boost preprocessor and wave not included yet for VC++ 10.0")
92 #ifndef NAMESPACE_IS_BROKEN
105 extern std::map<std::string,ROSEAttributesList* > mapFilenameToAttributes;
117 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
119 typedef boost::wave::cpplexer::lex_token<> token_type;
120 typedef std::vector<token_type> token_container;
121 typedef std::list<token_type> token_list_container;
122 typedef std::vector<std::list<token_type> > token_container_container;
157 CpreprocessorUnknownDeclaration,
161 CplusplusStyleComment,
172 CpreprocessorBlankLine,
175 CpreprocessorIncludeDeclaration,
176 CpreprocessorIncludeNextDeclaration,
177 CpreprocessorDefineDeclaration,
178 CpreprocessorUndefDeclaration,
179 CpreprocessorIfdefDeclaration,
180 CpreprocessorIfndefDeclaration,
181 CpreprocessorIfDeclaration,
182 CpreprocessorDeadIfDeclaration,
183 CpreprocessorElseDeclaration,
184 CpreprocessorElifDeclaration,
185 CpreprocessorEndifDeclaration,
186 CpreprocessorLineDeclaration,
187 CpreprocessorErrorDeclaration,
190 CpreprocessorWarningDeclaration,
191 CpreprocessorEmptyDeclaration,
210 ClinkageSpecificationStart,
211 ClinkageSpecificationEnd,
214 CpreprocessorIdentDeclaration,
226 CpreprocessorCompilerGeneratedLinemarker,
236 CpreprocessorEnd_ifDeclaration,
252 std::string internalString;
257 DirectiveType whatSortOfDirective;
263 int lineNumberForCompilerGeneratedLinemarker;
264 std::string filenameForCompilerGeneratedLinemarker;
265 std::string optionalflagsForCompilerGeneratedLinemarker;
272 bool p_isTransformation;
288 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
292 token_container* tokenStream;
299 token_type directive;
308 bool is_functionlike;
310 token_type macro_name;
311 token_container paramaters;
312 token_list_container definition;
313 r_macro_def() : macro_name(), paramaters(),definition() {}
320 typedef struct r_macro_call
322 bool is_functionlike;
324 token_type macro_call;
325 token_container_container arguments;
326 token_container expanded_macro;
329 std::string get_expanded_string()
331 std::ostringstream os;
332 token_container::const_iterator iter;
333 for (iter=expanded_macro.begin(); iter!=expanded_macro.end(); iter++)
334 os << (*iter).get_value();
338 r_macro_call() : macro_call(), arguments(),expanded_macro() {}
344 bool is_functionlike;
346 token_type macro_call;
347 token_container_container arguments;
348 token_container expanded_macro;
352 std::string get_expanded_string();
375 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
401 const std::string & filenameString,
int line_no ,
int col_no,
407 void display(
const std::string & label)
const;
410 int getLineNumber()
const;
411 int getColumnNumber()
const;
412 std::string getString()
const;
413 void setString (
const std::string & s );
414 int getStringLength()
const;
415 DirectiveType getTypeOfDirective()
const;
416 void setTypeOfDirective(DirectiveType);
421 std::string getFilename()
const;
422 int getFileId()
const;
425 int getNumberOfLines()
const;
426 int getColumnNumberOfEndOfString()
const;
433 static std::string directiveTypeName (
const DirectiveType & directive);
438 unsigned int packed_size ()
const;
441 char* packed()
const;
442 void unpacked(
char* storePointer );
450 std::string get_filename_from_include_directive();
453 int get_lineNumberForCompilerGeneratedLinemarker();
454 std::string get_filenameForCompilerGeneratedLinemarker();
455 std::string get_optionalflagsForCompilerGeneratedLinemarker();
458 void set_lineNumberForCompilerGeneratedLinemarker(
int x );
459 void set_filenameForCompilerGeneratedLinemarker( std::string x );
460 void set_optionalflagsForCompilerGeneratedLinemarker( std::string x );
463 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
473 const token_container* get_token_stream();
474 void push_front_token_stream(token_type tok);
475 void push_back_token_stream(token_type tok);
484 bool isSelfReferential();
485 std::string getMacroName();
488 bool isTransformation()
const;
489 void setAsTransformation();
490 void unsetAsTransformation();
497 typedef Rose_STL_Container<PreprocessingInfo*> AttachedPreprocessingInfoType;
503 std::vector<PreprocessingInfo*> attributeList;
509 LexTokenStreamTypePointer rawTokenStream;
513 std::string fileName;
525 std::set<int> filenameIdSet;
536 enum languageTypeEnum
538 e_unknown_language = 0,
541 e_Fortran77_language = 3,
542 e_Fortran9x_language = 4,
551 void addElement(PreprocessingInfo::DirectiveType,
const std::string & pLine,
const std::string & filename,
int lineNumber,
int columnNumber,
int numberOfLines);
567 void setFileName(
const std::string & fName);
568 std::string getFileName();
571 void setIndex(
int i);
577 void deepClean(
void);
584 std::vector<PreprocessingInfo*> & getList() {
return attributeList; };
586 void display (
const std::string & label );
589 void set_rawTokenStream( LexTokenStreamTypePointer s );
590 LexTokenStreamTypePointer get_rawTokenStream();
594 void generatePreprocessorDirectivesAndCommentsForAST(
const std::string & filename );
601 void collectPreprocessorDirectivesAndCommentsForAST(
const std::string & filename, languageTypeEnum languageType );
604 bool isFortran77Comment(
const std::string & line );
605 bool isFortran90Comment(
const std::string & line );
606 bool isCppDirective(
const std::string & line, PreprocessingInfo::DirectiveType & cppDeclarationKind, std::string & restOfTheLine );
611 void generateFileIdListFromLineDirectives();
614 std::set<int> & get_filenameIdSet();
635 std::map<std::string, ROSEAttributesList*> attributeListMap;
648 bool isInList (
const std::string & fName );
652 void dumpContents(
void);
653 void deepClean(
void);
659 std::map<std::string, ROSEAttributesList*> & getList() {
return attributeListMap; };
660 void display (
const std::string & label );
665 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
667 extern token_container wave_tokenStream;
This class represents a source file for a project (which may contian many source files and or directo...
This class represents the location of the code associated with the IR node in the original source cod...
RelativePositionType
MK: Enum type to store if the directive goes before or after the corresponding line of source code...
For preprocessing information including source comments, #include , #if, #define, etc...