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