1
2
3
4
5
6 #ifndef SNGCPP_AST_SOURCE_FILE_INCLUDED
7 #define SNGCPP_AST_SOURCE_FILE_INCLUDED
8 #include <sngcpp/ast/Namespace.hpp>
9 #include <string>
10 #include <vector>
11 #include <memory>
12
13 namespace sngcpp { namespace ast {
14
15 class SourceFileNode;
16
17 class SourceFileNode : public Node
18 {
19 public:
20 SourceFileNode();
21 SourceFileNode(const Span& span_, const std::string& sourceFilePath_, const std::string& relativeSourceFilePath_, const std::u32string& projectName_);
22 const std::string& SourceFilePath() const { return sourceFilePath; }
23 const std::string& RelativeSourceFilePath() { return relativeSourceFilePath; }
24 const std::u32string& ProjectName() const { return projectName; }
25 void SetHtmlSourceFilePath(const std::string& htmlSourceFilePath_) { htmlSourceFilePath = htmlSourceFilePath_; }
26 const std::string& HtmlSourceFilePath() const { return htmlSourceFilePath; }
27 const std::u32string& Id() const { return id; }
28 void SetSourceFileIndex(int sourceFileIndex_) { sourceFileIndex = sourceFileIndex_; }
29 int SourceFileIndex() const { return sourceFileIndex; }
30 void Accept(Visitor& visitor) override;
31 void Write(Writer& writer) override;
32 void Read(Reader& reader) override;
33 NamespaceNode* GlobalNs() { return globalNs.get(); }
34 void AddUsingDirectiveOrDeclaration(Node* usingDirectivesAndDeclaration);
35 const std::std::vector<Node*>&UsingDirectivesAndDeclarations() const{returnusingDirectivesAndDeclarations;}
36 bool Processed() const { return processed; }
37 void SetProcessed() { processed = true; }
38 void ComputeLineStarts();
39 std::std::vector<int>*LineStarts(){return&lineStarts;}
40 void SetContent(std::std::unique_ptr<std::u32string>&&content_){content = std::move(content_);}
41 void SetHeaderFilePaths(std::std::vector<std::string>&&headerFilePaths_){headerFilePaths = std::move(headerFilePaths_);}
42 const std::std::vector<std::string>&HeaderFilePaths() const{returnheaderFilePaths;}
43 void SetText(std::u32string&& text_) { text = std::move(text_); }
44 const std::u32string& Text() const { return text; }
45 private:
46 std::string sourceFilePath;
47 std::string relativeSourceFilePath;
48 std::u32string projectName;
49 std::string htmlSourceFilePath;
50 std::u32string id;
51 int sourceFileIndex;
52 std::unique_ptr<NamespaceNode> globalNs;
53 std::vector<Node*> usingDirectivesAndDeclarations;
54 bool processed;
55 std::vector<int> lineStarts;
56 std::unique_ptr<std::u32string> content;
57 std::vector<std::string> headerFilePaths;
58 std::u32string text;
59 };
60
61 class SourceFileSequenceNode : public BinaryNode
62 {
63 public:
64 SourceFileSequenceNode();
65 SourceFileSequenceNode(const Span& span_, Node* left_, Node* right_);
66 void Accept(Visitor& visitor) override;
67 };
68
69 void ResolveSourceFiles(Node* ast, std::std::vector<SourceFileNode*>&sourceFiles);
70
71 } }
72
73 #endif // SNGCPP_AST_SOURCE_FILE_INCLUDED