1
2
3
4
5
6 #ifndef SNGCM_AST_COMPILE_UNIT_INCLUDED
7 #define SNGCM_AST_COMPILE_UNIT_INCLUDED
8 #include <cmajor/common/Common.hpp>
9 #include <sngcm/ast/Namespace.hpp>
10
11 namespace sngcm { namespace ast {
12
13 class CompileUnitNode : public Node, public cmajor::common::ColumnSpanProvider
14 {
15 public:
16 CompileUnitNode(const Span& span_, const boost::uuids::uuid& moduleId_);
17 CompileUnitNode(const Span& span_, const boost::uuids::uuid& moduleId_, const std::string& filePath_);
18 Node* Clone(CloneContext& cloneContext) const override;
19 void Accept(Visitor& visitor) override;
20 const std::string& FilePath() const { return filePath; }
21 const NamespaceNode* GlobalNs() const { return globalNs.get(); }
22 NamespaceNode* GlobalNs() { return globalNs.get(); }
23 void ResetGlobalNs(NamespaceNode* ns);
24 void ComputeLineStarts(const std::u32string& sourceFileContent);
25 const std::std::vector<int32_t>&LineStarts(){returnlineStarts;}
26 void SetSynthesizedUnit() { isSynthesizedUnit = true; }
27 bool IsSynthesizedUnit() const { return isSynthesizedUnit; }
28 int GetColumn(const Span& span) const override;
29 const std::string& Id();
30 const std::string& Hash() const { return hash; }
31 void SetHash(const std::string& hash_) { hash = hash_; }
32 bool IsProgramMainUnit() const { return isProgramMainUnit; }
33 void SetProgramMainUnit() { isProgramMainUnit = true; }
34 private:
35 std::string filePath;
36 std::unique_ptr<NamespaceNode> globalNs;
37 std::vector<int32_t> lineStarts;
38 bool isSynthesizedUnit;
39 std::string id;
40 std::string hash;
41 bool isProgramMainUnit;
42 };
43
44 void CombineNamespaces(CompileUnitNode& cu);
45 void ArrangeClassMembers(CompileUnitNode& cu);
46 void AddNamespaceImportsForUnnamedNamespaces(CompileUnitNode& cu);
47
48 } }
49
50 #endif // SNGCM_AST_COMPILE_UNIT_INCLUDED