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;
158 CpreprocessorUnknownDeclaration,
162 CplusplusStyleComment,
173 CpreprocessorBlankLine,
176 CpreprocessorIncludeDeclaration,
177 CpreprocessorIncludeNextDeclaration,
178 CpreprocessorDefineDeclaration,
179 CpreprocessorUndefDeclaration,
180 CpreprocessorIfdefDeclaration,
181 CpreprocessorIfndefDeclaration,
182 CpreprocessorIfDeclaration,
183 CpreprocessorDeadIfDeclaration,
184 CpreprocessorElseDeclaration,
185 CpreprocessorElifDeclaration,
186 CpreprocessorEndifDeclaration,
187 CpreprocessorLineDeclaration,
188 CpreprocessorErrorDeclaration,
191 CpreprocessorWarningDeclaration,
192 CpreprocessorEmptyDeclaration,
211 ClinkageSpecificationStart,
212 ClinkageSpecificationEnd,
215 CpreprocessorIdentDeclaration,
227 CpreprocessorCompilerGeneratedLinemarker,
237 CpreprocessorEnd_ifDeclaration,
253 std::string internalString;
258 DirectiveType whatSortOfDirective;
264 int lineNumberForCompilerGeneratedLinemarker;
265 std::string filenameForCompilerGeneratedLinemarker;
266 std::string optionalflagsForCompilerGeneratedLinemarker;
273 bool p_isTransformation;
289 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
293 token_container* tokenStream;
300 token_type directive;
309 bool is_functionlike;
311 token_type macro_name;
312 token_container paramaters;
313 token_list_container definition;
314 r_macro_def() : macro_name(), paramaters(),definition() {}
321 typedef struct r_macro_call
323 bool is_functionlike;
325 token_type macro_call;
326 token_container_container arguments;
327 token_container expanded_macro;
330 std::string get_expanded_string()
332 std::ostringstream os;
333 token_container::const_iterator iter;
334 for (iter=expanded_macro.begin(); iter!=expanded_macro.end(); iter++)
335 os << (*iter).get_value();
339 r_macro_call() : macro_call(), arguments(),expanded_macro() {}
345 bool is_functionlike;
347 token_type macro_call;
348 token_container_container arguments;
349 token_container expanded_macro;
353 std::string get_expanded_string();
376 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
402 const std::string & filenameString,
int line_no ,
int col_no,
408 void display(
const std::string & label)
const;
411 int getLineNumber()
const;
412 int getColumnNumber()
const;
413 std::string getString()
const;
414 void setString (
const std::string & s );
415 int getStringLength()
const;
416 DirectiveType getTypeOfDirective()
const;
417 void setTypeOfDirective(DirectiveType);
422 std::string getFilename()
const;
423 int getFileId()
const;
426 int getNumberOfLines()
const;
427 int getColumnNumberOfEndOfString()
const;
434 static std::string directiveTypeName (
const DirectiveType & directive);
439 unsigned int packed_size ()
const;
442 char* packed()
const;
443 void unpacked(
char* storePointer );
451 std::string get_filename_from_include_directive();
454 int get_lineNumberForCompilerGeneratedLinemarker();
455 std::string get_filenameForCompilerGeneratedLinemarker();
456 std::string get_optionalflagsForCompilerGeneratedLinemarker();
459 void set_lineNumberForCompilerGeneratedLinemarker(
int x );
460 void set_filenameForCompilerGeneratedLinemarker( std::string x );
461 void set_optionalflagsForCompilerGeneratedLinemarker( std::string x );
464 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
474 const token_container* get_token_stream();
475 void push_front_token_stream(token_type tok);
476 void push_back_token_stream(token_type tok);
485 bool isSelfReferential();
486 std::string getMacroName();
489 bool isTransformation()
const;
490 void setAsTransformation();
491 void unsetAsTransformation();
498 typedef Rose_STL_Container<PreprocessingInfo*> AttachedPreprocessingInfoType;
504 std::vector<PreprocessingInfo*> attributeList;
510 LexTokenStreamTypePointer rawTokenStream;
514 std::string fileName;
526 std::set<int> filenameIdSet;
537 enum languageTypeEnum
539 e_unknown_language = 0,
542 e_Fortran77_language = 3,
543 e_Fortran9x_language = 4,
552 void addElement(PreprocessingInfo::DirectiveType,
const std::string & pLine,
const std::string & filename,
int lineNumber,
int columnNumber,
int numberOfLines);
568 void setFileName(
const std::string & fName);
569 std::string getFileName();
572 void setIndex(
int i);
578 void deepClean(
void);
585 std::vector<PreprocessingInfo*> & getList() {
return attributeList; };
587 void display (
const std::string & label );
590 void set_rawTokenStream( LexTokenStreamTypePointer s );
591 LexTokenStreamTypePointer get_rawTokenStream();
595 void generatePreprocessorDirectivesAndCommentsForAST(
const std::string & filename );
602 void collectPreprocessorDirectivesAndCommentsForAST(
const std::string & filename, languageTypeEnum languageType );
605 bool isFortran77Comment(
const std::string & line );
606 bool isFortran90Comment(
const std::string & line );
607 bool isCppDirective(
const std::string & line, PreprocessingInfo::DirectiveType & cppDeclarationKind, std::string & restOfTheLine );
612 void generateFileIdListFromLineDirectives();
615 std::set<int> & get_filenameIdSet();
636 std::map<std::string, ROSEAttributesList*> attributeListMap;
649 bool isInList (
const std::string & fName );
653 void dumpContents(
void);
654 void deepClean(
void);
660 std::map<std::string, ROSEAttributesList*> & getList() {
return attributeListMap; };
661 void display (
const std::string & label );
666 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
668 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.