ROSE  0.11.98.0
Driver.h
1 #ifndef ROSE_CodeGen_Driver_H
2 #define ROSE_CodeGen_Driver_H
3 
4 #include <set>
5 #include <map>
6 #include <string>
7 
8 #include <boost/filesystem.hpp>
9 
10 class SgProject;
11 class SgSourceFile;
12 class SgScopeStatement;
13 class SgSymbol;
14 class SgGlobal;
15 
16 namespace Rose { namespace CodeGen {
17 
21 class Driver {
22  public:
24 
25  private:
26  size_t file_id_counter;
27  std::map<boost::filesystem::path, size_t> path_to_id_map;
28  std::map<size_t, SgSourceFile *> id_to_file_map;
29  std::map<SgSourceFile *, size_t> file_to_id_map;
30  std::map<size_t, std::set<size_t> > file_id_to_accessible_file_id_map;
31 
32  void init(SgProject * project_);
33  size_t add(SgSourceFile * file);
34 
35  public:
36  Driver();
37  Driver(SgProject * project_);
38  Driver(std::vector<std::string> & args);
39 
41  void addCxxExtension(std::string) const;
42 
44  size_t create(const boost::filesystem::path & path);
45  size_t add(const boost::filesystem::path & path);
46 
49  size_t getFileID(const boost::filesystem::path & path) const;
50  size_t getFileID(SgSourceFile * source_file) const;
51  size_t getFileID(SgScopeStatement * scope) const;
53 
55  SgGlobal * getGlobalScope(size_t file_id) const;
56 
58  SgSourceFile * getSourceFile(size_t file_id) const;
59 
61  void setUnparsedFile(size_t file_id) const;
62 
64  void setCompiledFile(size_t file_id) const;
65 
67  void addExternalHeader(size_t file_id, std::string header_name, bool is_system_header = true) const;
68 
70  void addPragmaDecl(size_t file_id, std::string str) const;
71 
72  template <typename ContainerFileID0, typename ContainerFileID1>
73  void exportNameQualification(ContainerFileID0 const & unparsed_ids, ContainerFileID1 const & header_ids) const {
74  for (auto unparsed_id: unparsed_ids) {
75  auto & extra_nodes_for_namequal_init = getSourceFile(unparsed_id)->get_extra_nodes_for_namequal_init();
76  for (auto header_id: header_ids) {
77  extra_nodes_for_namequal_init.push_back(getGlobalScope(header_id));
78  }
79  }
80  }
81 };
82 
83 } }
84 
85 #endif
void addPragmaDecl(size_t file_id, std::string str) const
Add a pragma at the begining of the file.
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope, etc.).
void setUnparsedFile(size_t file_id) const
Set a file to be unparsed with the project (by default file added to the driver are NOT unparsed) ...
SgProject * project
the Rose project
Definition: Driver.h:23
void setCompiledFile(size_t file_id) const
Set a file to be compiled with the project (by default file added to the driver are NOT compiled) ...
void addCxxExtension(std::string) const
Utility method to add possible C++ extensions (hxx/hpp are not recognized by ROSE as source-file) ...
SgSourceFile * getSourceFile(size_t file_id) const
Retrieve the source-file node from a file-id.
Main namespace for the ROSE library.
facilitates the manipulation of source-files (esp.
Definition: Driver.h:21
This class represents the concept of a name within the compiler.
void addExternalHeader(size_t file_id, std::string header_name, bool is_system_header=true) const
Insert external header for a given file.
size_t getFileID(const boost::filesystem::path &path) const
Retrieve file-id of associated with a file.
This class represents the concept of a namespace definition.
size_t create(const boost::filesystem::path &path)
Create a file ()
This class represents a source project, with a list of SgFile objects and global information about th...
SgGlobal * getGlobalScope(size_t file_id) const
Retrieve the global scope of a file from its file-id.