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