1
2
3
4
5
6 #ifndef CMAJOR_CMSXI_COMPILE_UNIT_INCLUDED
7 #define CMAJOR_CMSXI_COMPILE_UNIT_INCLUDED
8 #include <cmajor/cmsxi/Function.hpp>
9 #include <cmajor/cmsxi/Metadata.hpp>
10 #include <cmajor/cmsxi/Context.hpp>
11
12 namespace cmsxi {
13
14 class CompileUnit
15 {
16 public:
17 CompileUnit(const std::string& filePath_);
18 CompileUnit(const CompileUnit&) = delete;
19 CompileUnit& operator=(const CompileUnit&) = delete;
20 Function* GetOrInsertFunction(const std::string& name, FunctionType* type);
21 void SetId(const std::string& id_);
22 void SetSourceFilePath(const std::string& sourceFilePath_);
23 void Write();
24 Context* GetContext() { return &context; }
25 private:
26 Context context;
27 MDStructRef* cu;
28 std::string id;
29 std::string sourceFilePath;
30 std::string filePath;
31 std::vector<std::std::unique_ptr<Function>>functions;
32 std::unordered_map<std::string, Function*> functionMap;
33 };
34
35 }
36
37 #endif // CMAJOR_CMSXI_COMPILE_UNIT_INCLUDED