ROSE  0.11.28.0
rose_attributes_list.h
1 #ifndef __ROSEAttributesList_H__
2 #define __ROSEAttributesList_H__
3 
4 //#include "setup.h"
5 
6 //#include <list>
7 //#include <vector>
8 #include <map>
9 
10 // Include the ROSE lex specific definitions of tokens
11 #include "general_token_defs.h"
12 
13 // #ifdef CAN_NOT_COMPILE_WITH_ROSE
14 // #warning "CAN_NOT_COMPILE_WITH_ROSE IS defined"
15 // #else
16 // #warning "CAN_NOT_COMPILE_WITH_ROSE is NOT defined"
17 // #endif
18 
19 // DQ (2/28/2010): Skip this if we are compiling ROSE using ROSE.
20 // This is being used in place of the CAN_NOT_COMPILE_WITH_ROSE macro.
21 // Note that CAN_NOT_COMPILE_WITH_ROSE is set by the following projects:
22 // 1) projects/DocumentationGenerator
23 // 2) projects/haskellport
24 // in their Makefile.am files. I think that using CXX_IS_ROSE_ANALYSIS
25 // will be equivalent (used to indicate the a ROSE translator is being
26 // used to compile the ROSE source code).
27 // However, it might be that this is equivalent to the USE_ROSE macro,
28 // which is set for all ROSE translators when they compile any code.
29 // DQ (12/22/2008): I would appreciate it if this were a better name...
30 // #if !CAN_NOT_COMPILE_WITH_ROSE
31 // #ifndef USE_ROSE
32 
33 // DQ (5/21/2010): I have built a separate macro for tuning off the compilation of WAVE
34 // since it is done only for the purpose of allowing ROSE based projects:
35 // 1) projects/DocumentationGenerator
36 // 2) projects/haskellport
37 // to process the ROSE files cleanly. ROSE can however process and compile ROSE
38 // (including a slightly modified version of WAVE that EDG will accept) and we
39 // separately test this in noightly tests. The previous 5/18/2010 fix to permit
40 // the Haskell support to skip processign WAVE turned this off and broke the nightly
41 // tests of ROSE compiling ROSE. This use of the macro ROSE_SKIP_COMPILATION_OF_WAVE
42 // it menat to be turned on by ROSE based tools that need to process the ROSE code
43 // and which currently fail (because of Wave) and so turn of the processing of Wave
44 // for those tools.
45 // #ifdef USE_ROSE
46 // #define ROSE_SKIP_COMPILATION_OF_WAVE
47 // #endif
48 
49 // DQ (2/27/2016): Check for DEBIAN and Boost 1.54 and disable WAVE (not found in
50 // Boost 1.54, for Debian OS installations, as I understand it). This is a fix
51 // for a bug identified to be specific to Boost 1.54 on Debian systems, so that
52 // is why it is so specific in deactivating boost::wave. To support this the
53 // boost::wave support had to be revisited to permit it to NOT be a dependence.
54 // We shuld put in place tests that make sure it does not accedently become a
55 // dependence in the future.
56 #ifdef ROSE_DEBIAN_OS_VENDOR
57  #if (ROSE_BOOST_VERSION == 105400)
58  #define ROSE_SKIP_COMPILATION_OF_WAVE
59  #endif
60 #endif
61 
62 #if __sun
63  // PP 05/16/19
64  // Continue skipping WAVE until it is needed
65  // (after boost 1.65 is working on Solaris, WAVE should also work)
66  #define ROSE_SKIP_COMPILATION_OF_WAVE
67 #endif
68 
69 // DQ (2/27/2016): Test compilation of ROSE without boost::wave support.
70 // #define ROSE_SKIP_COMPILATION_OF_WAVE
71 
72 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
73 // #if _MSC_VER < 1600 // 1600 == VC++ 10.0
74  #if (!defined(_MSC_VER) || (_MSC_VER > 1600))
75  #include <boost/preprocessor/iteration/iterate.hpp> // Liao, 7/10/2009, required by GCC 4.4.0 for a #define line of BOOST_PP_ITERATION_DEPTH
76  #ifdef _MSC_VER
77  #include <boost/wave.hpp> // CH (4/7/2010): Put this header here to avoid compiling error about mismatch between defination and declaration
78  #endif
79  #include <boost/wave/cpplexer/cpp_lex_token.hpp> // token class
80  #include <boost/wave/cpplexer/cpp_lex_iterator.hpp> // lexer type
81  #else
82 // #warning "Setting CAN_NOT_COMPILE_WITH_ROSE to value = 1"
83 // #define CAN_NOT_COMPILE_WITH_ROSE 1
84 // tps (12/4/2009) : This is not found in VC++ 10.0 and Boost 1.4
85  #pragma message ("Boost preprocessor and wave not included yet for VC++ 10.0")
86 
87  #endif
88 #endif
89 
90 //template boost::wave::cpplexer::impl::token_data<std::string, boost::wave::util::file_position_type>::delete(std::size_t) ;
91 // DQ (10/16/2002): Required for compiling with SUN 5.2 C++ compiler
92 #ifndef NAMESPACE_IS_BROKEN
93 // DQ (12/30/2005): This is a Bad Bad thing to do (I can explain)
94 // it hides names in the global namespace and causes errors in
95 // otherwise valid and useful code. Where it is needed it should
96 // appear only in *.C files (and only ones not included for template
97 // instantiation reasons) else they effect user who use ROSE unexpectedly.
98 // using namespace std;
99 #endif
100 
101 class ROSE_DLL_API PreprocessingInfo;
102 class ROSEAttributesList;
103 //AS(01/04/07) Global map of filenames to PreprocessingInfo*'s as it is inefficient
104 //to get this by a traversal of the AST
105 extern std::map<std::string,ROSEAttributesList* > mapFilenameToAttributes;
106 
107 
108 // DQ (4/19/2006): Forward declaration so that PreprocessingInfo can
109 // contain a pointer to a Sg_File_Info object.
110 class Sg_File_Info;
111 
112 // DQ (1/21/2008): Need forward declaration
113 class SgFile;
114 
115 // #if !CAN_NOT_COMPILE_WITH_ROSE
116 // #ifndef USE_ROSE
117 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
118 
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;
123 
124 #endif
125 
128  {
129  public:
130  // DQ (10/15/2002) moved this to nested scope to avoid global name pollution :-).
134  {
135  defaultValue = 0, // let the zero value be an error value
136  undef = 1, // Position of the directive is only going to be defined
137  // when the preprocessing object is copied into the AST,
138  // it remains undefined before that
139  before = 2, // Directive goes before the correponding code segment
140  after = 3, // Directive goes after the correponding code segment
141  inside = 4, // Directive goes inside the correponding code segment (as in between "{" and "}" of an empty basic block)
142 
143  // DQ (7/19/2008): Added additional fields so that we could use this enum type in the AstUnparseAttribute
144  // replace = 5, // Support for replacing the IR node in the unparsing of any associated subtree
145  before_syntax = 6, // We still have to specify the syntax
146  after_syntax = 7 // We still have to specify the syntax
147  };
148 
149  // Enum type to help classify the type for string that has been saved.
150  // This helps in the unparsing to make sure that line feeds are introduced properly.
151  //
152  // Rama (08/17/07): Adding a CpreprocessorDeadIfDeclaration and its support
153  // in various files.
154  enum DirectiveType
155  {
156  // This is treated as an error
157  CpreprocessorUnknownDeclaration,
158 
159  // These are a classification for comments
160  C_StyleComment,
161  CplusplusStyleComment,
162  FortranStyleComment,
163 
164  // FMZ(5/14/2010): Added freeform comments (started with "!")
165  F90StyleComment,
166 
167  // Rasmussen (11/3/2020): Added Ada and Jovial comments
168  AdaStyleComment,
169  JovialStyleComment,
170 
171  // DQ (11/20/2008): Added classification for blank line (a language independent form of comment).
172  CpreprocessorBlankLine,
173 
174  // These used to be translated into IR nodes (and will be in the future).
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,
188 
189  // DQ (10/19/2005): Added CPP warning directive
190  CpreprocessorWarningDeclaration,
191  CpreprocessorEmptyDeclaration,
192 
193  // AS (11/18/05): Added macro support (these are generated by the Wave
194  // support, but need to be better documented as to what they mean).
195  CSkippedToken,
196  CMacroCall,
197 
198  // AS & LIAO (8/12/2008): A PreprocessingInfo that is a
199  // hand made MacroCall that will expand into a valid statement.
200  CMacroCallStatement,
201 
202  // DQ (11/28/2008): What does this mean!
203  // A line replacement will replace a sub-tree in the AST
204  // after a node with position (filename,line)
205  LineReplacement,
206 
207  // The is the 'extern "C" {' construct. Note that this is not captured in
208  // the EDG AST and it is required to be captured as part of the CPP and
209  // comment preprocessing.
210  ClinkageSpecificationStart,
211  ClinkageSpecificationEnd,
212 
213  // DQ (11/17/2008): Added support for #ident
214  CpreprocessorIdentDeclaration,
215 
216  // DQ (11/17/2008): This handles the case CPP declarations (called "linemarkers")
217  // (see Google for more details) such as: "# 1 "test2008_05.F90"", "# 1 "<built-in>"",
218  // "# 1 "<command line>"" "# 1 "test2008_05.F90""
219  // The first token is the line number,
220  // the second token is the filename (or string),
221  // the optional tokens (zero or more) are flags:
222  // '1' indicates the start of a new file.
223  // '2' indicates returning to a file (having included another file).
224  // '3' indicates that the following text comes from a system header file, so certain warnings should be supressed.
225  // '4' indicates that the following text should be treated as being wrapped in an implicit 'extern "C"' block
226  CpreprocessorCompilerGeneratedLinemarker,
227 
228  // DQ (2/2/2014): permit raw text to be specified as a extremely simple way to add text to the unparsing of the AST.
229  // Note that it is the user's responcability to have the text be legal code. Additionall any language constructs
230  // added using this mechanism will ot show up in the AST. So it is not possible to reference functions (for example)
231  // added using this mechanism to build function calls as transformation elsewhere in the code. But one could add
232  // the function via AST transformations and the function body using a mechanism provided here and that would define
233  // a simple appoach to adding large complex functions for which it is impractical to build up an AST.
234  RawText,
235 
236  LastDirectiveType
237  };
238 
239  // DQ (7/10/2004): Make the data private
240  private:
241 
242  // DQ (4/19/2006): Use the SgFileInfo object to hold the more complete
243  // information about the filename, line number, and column number.
244  Sg_File_Info* file_info;
245  // int lineNumber;
246  // int columnNumber;
247 
248  // Use string class to improve implementation
249  // char* stringPointer;
250  std::string internalString;
251 
252  int numberOfLines;
253 
254  // enum value representing a classification of the different types of directives
255  DirectiveType whatSortOfDirective;
256 
257  // Corresponding enum value
258  RelativePositionType relativePosition;
259 
260  // DQ (11/28/2008): Support for CPP generated linemarkers
261  int lineNumberForCompilerGeneratedLinemarker;
262  std::string filenameForCompilerGeneratedLinemarker;
263  std::string optionalflagsForCompilerGeneratedLinemarker;
264 
265  // DQ (1/15/2015): Adding support for token-based unparsing. When new comments and CPP directives are added we need
266  // to record these as a kind of transformation that will trigger the token stream representation to NOT be used and
267  // the comments and CPP directives unparsed from the AST seperately from the associated IR node being unparsed from
268  // the AST. The problem is that we wnat to record where there might be comments or CPP directives removed and having
269  // a flag here is not going to work for that. so we have to also record that the ROSEAttributesList has changed.
270  bool p_isTransformation;
271 
272 // This is part of Wave support in ROSE.
273 // #ifndef USE_ROSE
274  public:
275 /*
276  // AS using the lexer_token from boost_wave in order to store structures
277  typedef boost::wave::cpplexer::lex_token<> token_type;
278  typedef std::vector<token_type> token_container;
279  typedef std::list<token_type> token_list_container;
280  typedef std::vector<std::list<token_type> > token_container_container;
281 */
282  private:
283  // FIXME: To support Jochens AST binary save work the tokenSteam must
284  // have a pointer type.
285 
286 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
287  // A stream of tokens representing the current prerpocessing info
288  // object. This is equivalent to the internal string, but of cause
289  // contains more information since it is a tokenized stream.
290  token_container* tokenStream;
291 
292  public:
293  typedef struct r_include_directive
294  {
295  // The parameter 'directive' contains the (expanded) file name found after
296  // the #include directive. This has the format '<file>', '"file"' or 'file'.
297  token_type directive;
298  // The paths plus name to the include directive filename
299  std::string absname;
300  std::string relname;
302 
303  // Internal representation of a macro #define directive
304  typedef struct r_macro_def
305  {
306  bool is_functionlike;
307  bool is_predefined;
308  token_type macro_name;
309  token_container paramaters;
310  token_list_container definition;
311  r_macro_def() : macro_name(), paramaters(),definition() {}
313 
314  // Internal representation of a macro call
315  // e.g #define MACRO_CALL int x;
316  // MACRO_CALL
317 #if 0
318  typedef struct r_macro_call
319  {
320  bool is_functionlike;
321  PreprocessingInfo* macro_def;
322  token_type macro_call;
323  token_container_container arguments;
324  token_container expanded_macro;
325 
326  // Get string representation of the expanded macro
327  std::string get_expanded_string()
328  {
329  std::ostringstream os;
330  token_container::const_iterator iter;
331  for (iter=expanded_macro.begin(); iter!=expanded_macro.end(); iter++)
332  os << (*iter).get_value();
333  return os.str();
334  }
335 
336  r_macro_call() : macro_call(), arguments(),expanded_macro() {}
337  } rose_macro_call;
338 #else
339  // DQ (3/9/2013): Modified to address SWIG error.
341  {
342  bool is_functionlike;
343  PreprocessingInfo* macro_def;
344  token_type macro_call;
345  token_container_container arguments;
346  token_container expanded_macro;
347 
348  // DQ (3/9/2013): The function definition is moved to the source file to get around SWIG error.
349  // Get string representation of the expanded macro
350  std::string get_expanded_string();
351 
352  // DQ (3/9/2013): The function definition is moved to the source file to get around SWIG error.
353  rose_macro_call();
354  };
355 #endif
356 
357  private:
358  // AS add macro definition
359  rose_macro_definition* macroDef;
360  // AS add macro call
361  rose_macro_call* macroCall;
362  // AS include directive
363  rose_include_directive* includeDirective;
364 
365 #endif
366 
367  // member functions
368  public:
371 
372 // #ifndef USE_ROSE
373 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
374  // AS (112105) Added constructors to support macros
375  PreprocessingInfo(token_container, DirectiveType, RelativePositionType);
378  PreprocessingInfo(token_type, token_list_container, bool, DirectiveType,RelativePositionType);
380 #endif
381 
382  // This constructor is called from the C++ code generated from the lex file (preproc.lex)
383  // PreprocessingInfo(DirectiveType, const char *inputStringPointer, int line_no , int col_no,
384  // int nol, RelativePositionType relPos, bool copiedFlag, bool unparsedFlag) ROSE_DEPRECATED_FUNCTION;
385 
386  // DQ (7/19/2008): I have removed the bool copiedFlag and bool unparsedFlag parameters because they are not used
387  // and are present only because in an older implementation of the unparser it would make the PreprocessingInfo
388  // as unparsed (and maybe copied) but this sort of side-effect of the unparser was later removed to make the
389  // unparsing side-effect free.
390  // DQ (4/19/2006): Use the SgFileInfo object to hold the more complete
391  // information about the filename, line number, and column number.
392  // DQ (3/15/2006): Build constructor that uses C++ string as input (to replace the char* based constructor)
393  // PreprocessingInfo(DirectiveType, const std::string inputString, int line_no , int col_no,
394  // int nol, RelativePositionType relPos, bool copiedFlag, bool unparsedFlag);
395  // PreprocessingInfo(DirectiveType, const std::string & inputString,
396  // const std::string & filenameString, int line_no , int col_no,
397  // int nol, RelativePositionType relPos, bool copiedFlag, bool unparsedFlag );
398  PreprocessingInfo(DirectiveType, const std::string & inputString,
399  const std::string & filenameString, int line_no , int col_no,
400  int nol, RelativePositionType relPos );
401 
402  // Copy constructor
403  PreprocessingInfo(const PreprocessingInfo &prepInfo);
404 
405  void display(const std::string & label) const;
406 
407  // Access functions
408  int getLineNumber() const;
409  int getColumnNumber() const;
410  std::string getString() const;
411  void setString ( const std::string & s );
412  int getStringLength() const;
413  DirectiveType getTypeOfDirective() const;
414  RelativePositionType getRelativePosition(void) const;
415  void setRelativePosition(RelativePositionType relPos);
416 
417  // DQ (2/27/2019): Adding support for CPP directives and comments to have filename information (already present, but we need to access it).
418  std::string getFilename() const;
419  int getFileId() const;
420 
421  // Number of lines occupied by this comment (count the number of line feeds)
422  int getNumberOfLines() const;
423  int getColumnNumberOfEndOfString() const; // only correct for single line directives
424 
425  // Used in unparse to string mechanism
426  // char* removeLeadingWhiteSpace (const char* inputStringPointer);
427 
428  // DQ (8/6/2006): Modified to make these static functions
429  // useful for debugging
430  static std::string directiveTypeName (const DirectiveType & directive);
431  static std::string relativePositionName (const RelativePositionType & position);
432 
433  // JH (01/03/2006) methods for packing the PreprocessingInfo data, in order to store it into
434  // a file and rebuild it!
435  unsigned int packed_size () const;
436 
437  // JH (01/032006) This pack methods might cause memory leaks. Think of deleting them after stored to file ...
438  char* packed() const;
439  void unpacked( char* storePointer );
440 
441  // DQ (4/19/2006): Added Sg_File_Info objects to each PreprocessingInfo object
442  Sg_File_Info* get_file_info() const;
443  void set_file_info( Sg_File_Info* info );
444 
445  // DQ (8/26/2020): include directive have a filename imbedded inside, and we need to
446  // extract that for from tools (e.g. the fixup for initializers from include files).
447  std::string get_filename_from_include_directive();
448 
449  // DQ (11/28/2008): Support for CPP generated linemarkers
450  int get_lineNumberForCompilerGeneratedLinemarker();
451  std::string get_filenameForCompilerGeneratedLinemarker();
452  std::string get_optionalflagsForCompilerGeneratedLinemarker();
453 
454  // DQ (11/28/2008): Support for CPP generated linemarkers
455  void set_lineNumberForCompilerGeneratedLinemarker( int x );
456  void set_filenameForCompilerGeneratedLinemarker( std::string x );
457  void set_optionalflagsForCompilerGeneratedLinemarker( std::string x );
458 
459 // #ifndef USE_ROSE
460 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
461  // Wave specific member functions.
462  public:
463  // Access functions to get the macro call or macro definition.
464  // These are NULL if the type is not CMacroCall or
465  // CpreprocessorDefineDeclaration
466  rose_macro_call* get_macro_call();
467  rose_macro_definition* get_macro_def();
468  rose_include_directive* get_include_directive();
469 
470  const token_container* get_token_stream();
471  void push_front_token_stream(token_type tok);
472  void push_back_token_stream(token_type tok);
473 
474 #endif
475 
476  // DQ (12/30/2013): Adding support to supress output of macros that are self-referential.
477  // e.g. "#define foo X->foo", which would be expanded a second time in the backend processing.
478  // Note that if we don't output the #define, then we still might have a problem if there was
479  // code that depended upon a "#ifdef foo". So this handling is not without some risk, but it
480  // always better to use the token stream unparsing for these cases.
481  bool isSelfReferential();
482  std::string getMacroName();
483 
484  // DQ (1/15/2015): Adding support for token-based unparsing. Access function for new data member.
485  bool isTransformation() const;
486  void setAsTransformation();
487  void unsetAsTransformation();
488  };
489 
490 // DQ (10/15/2002) Changed list element from "PreprocessingInfo" to
491 // "PreprocessingInfo*" to avoid redundant copying of internal data.
492 // Define a new data type for the container that stores the
493 // PreprocessingInfo objects attached to an AST node
494 typedef Rose_STL_Container<PreprocessingInfo*> AttachedPreprocessingInfoType;
495 
497  {
498  private:
499  // DQ replaced use of old list class with STL
500  std::vector<PreprocessingInfo*> attributeList;
501 
502  // DQ (1/9/2021): Added comment.
503  // Note that the token stream is contained in the ROSEAttributesList list which before this just held
504  // the comments and CPP directives. This is OK, but the makes of the types and data members are less
505  // than ideal.
506  LexTokenStreamTypePointer rawTokenStream;
507 
508  // [DT] 3/15/2000 -- Name of file from which the directives come.
509  // char fileName[256];
510  std::string fileName;
511 
512  // 3/16/2000 -- Index into the list. Not sure if this is really
513  // necessary. See implementation in unparser.C.
514  //
515  // This is where the current line number is stored while we
516  // go off and unparse a different include file. This really should have
517  // been stored in a static structure (I think) rather than in this list.
518  int index;
519 
520  // DQ (12/15/2012): Save file ids that are from filenames referenced in #line
521  // directives, these will be considered equivalent to the input source filename.
522  std::set<int> filenameIdSet;
523 
524  // DQ (1/15/2015): Adding support for token-based unparsing. When new comments and CPP directives are added we need
525  // to record these as a kind of transformation that will trigger the token stream representation to NOT be used and
526  // the comments and CPP directives unparsed from the AST seperately from the associated IR node being unparsed from
527  // the AST. The problem is that we want to record where there might be comments or CPP directives removed and having
528  // a flag here is not going to work for that, so we have to also record that the ROSEAttributesList has changed.
529  // bool p_isTransformation;
530 
531  public:
532  // DQ (11/19/2008): Added language selection support for handling comments
533  enum languageTypeEnum
534  {
535  e_unknown_language = 0,
536  e_C_language = 1,
537  e_Cxx_language = 2,
538  e_Fortran77_language = 3,
539  e_Fortran9x_language = 4,
540  e_lastLanguage
541  };
542 
545  // DQ (4/19/2006): Adding SgFileInfo objects so we need to pass in a filename string
546  // void addElement(PreprocessingInfo::DirectiveType, const char *pLine, int lineNumber, int columnNumber, int numberOfLines);
547  void addElement(PreprocessingInfo::DirectiveType, const std::string & pLine, const std::string & filename, int lineNumber, int columnNumber, int numberOfLines);
548 #if 1
549  // DQ (5/9/2007): This is required for WAVE support.
550  // DQ (4/13/2007): I would like to remove this function, but it is used by WAVE support within ROSE.
551  void addElement( PreprocessingInfo &pRef );
552 #endif
553  // void addElements( ROSEAttributesList &);
554  void moveElements( ROSEAttributesList &);
555 
556 #if 1
557  // DQ (5/9/2007): This is required for WAVE support.
558  // DQ (4/13/2007): I would like to remove this function
559  void insertElement( PreprocessingInfo & pRef );
560 #endif
561 
562  // [DT] 3/15/2000 -- Interface to fileName member.
563  void setFileName(const std::string & fName);
564  std::string getFileName();
565 
566  // 3/16/2000 -- Interface to index member.
567  void setIndex(int i);
568  int getIndex();
569 
570  PreprocessingInfo* operator[](int i);
571  int size(void);
572  int getLength(void);
573  void deepClean(void);
574  void clean(void);
575 
576  // DQ (9/19/2013): generate the number associated with each position relative to the attached IR node.
577  // size_t numberByRelativePosition(PreprocessingInfo::RelativePositionType pos);
578 
579  // Access function for list
580  std::vector<PreprocessingInfo*> & getList() { return attributeList; };
581 
582  void display ( const std::string & label ); // DQ 02/18/2001 -- For debugging.
583 
584  // DQ (1/21/2008): Added access function to save the raw token stream from the lex pass.
585  void set_rawTokenStream( LexTokenStreamTypePointer s );
586  LexTokenStreamTypePointer get_rawTokenStream();
587 
588  // This function processes the token stream to generate the input for what weaves the
589  // CPP directives and comments into the AST. All other tokens are ignore in this pass.
590  void generatePreprocessorDirectivesAndCommentsForAST( const std::string & filename );
591 
592  // DQ (11/26/2008): This is old code!
593  // Collection comments and CPP directives for fixed format (easier case)
594  // void collectFixedFormatPreprocessorDirectivesAndCommentsForAST( const std::string & filename );
595 
596  // DQ (11/16/2008): Adding support for recognition of CPP directives outside of the lex tokenization.
597  void collectPreprocessorDirectivesAndCommentsForAST( const std::string & filename, languageTypeEnum languageType );
598 
599  // DQ (11/17/2008): Refactored the code.
600  bool isFortran77Comment( const std::string & line );
601  bool isFortran90Comment( const std::string & line );
602  bool isCppDirective( const std::string & line, PreprocessingInfo::DirectiveType & cppDeclarationKind, std::string & restOfTheLine );
603 
604  // DQ (12/15/2012): traverse the attributeList and process all of the #line directives to generate a
605  // list of file ids that should be considered equivalent to that of the input source file's filename.
606  // std::set<int> generateFileIdListFromLineDirectives();
607  void generateFileIdListFromLineDirectives();
608 
609  // DQ (12/15/2012): Added access function.
610  std::set<int> & get_filenameIdSet();
611 
612  // DQ (9/29/2013): Added to support adding processed CPP directives and comments as tokens to token list.
613  PreprocessingInfo* lastElement();
614 
615  // DQ (1/15/2015): Adding support for token-based unparsing. Access function for new data member.
616  // bool isTransformation() const;
617  // void setAsTransformation();
618  // void unsetAsTransformation();
619  };
620 
621 //
622 // [DT] 3/16/2000 -- Want to have preprocessing info for
623 // each file included from the main source file.
624 //
626  {
627  private:
628  // DQ replaced use of old list class with STL
629  // std::vector<ROSEAttributesList*> attributeListList;
630  // std::map<std::string,ROSEAttributesList*>* attrMap;
631  std::map<std::string, ROSEAttributesList*> attributeListMap;
632 
633  public:
636  // void addList ( ROSEAttributesList* listPointer );
637  void addList ( std::string fileName, ROSEAttributesList* listPointer );
638  // void addList(ROSEAttributesList &aRef);
639  // void insertList(ROSEAttributesList &aRef);
640  // ROSEAttributesList* operator[](int i);
641  // ROSEAttributesList* findList ( const std::string & fName );
642 
643  // Check to see if the ROSEAttributesList for the fName (filename) is in the container
644  bool isInList ( const std::string & fName );
645 
646  // int size(void);
647  // int getLength(void);
648  void dumpContents(void); // [DT] 3/16/2000 -- For debugging.
649  void deepClean(void);
650  void clean(void);
651  ROSEAttributesList & operator[]( const std::string & fName);
652 
653  // Access function for list
654  // std::vector<ROSEAttributesList*> & getList() { return attributeListList; };
655  std::map<std::string, ROSEAttributesList*> & getList() { return attributeListMap; };
656  void display ( const std::string & label ); // DQ 02/18/2001 -- For debugging.
657  };
658 
659 
660 // #ifndef USE_ROSE
661 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
662 
663 extern token_container wave_tokenStream;
664 
665 #endif
666 
667 #endif
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...