Line data Source code
1 : #ifndef AST_CHAINED_H
2 : #define AST_CHAINED_H
3 :
4 : #include "../ast.h"
5 : #include <memory>
6 : #include <vector>
7 :
8 : namespace nicole {
9 :
10 : class AST_CHAINED final : public AST {
11 : private:
12 : std::shared_ptr<AST> base_;
13 : std::vector<std::shared_ptr<AST>> operations_;
14 :
15 : public:
16 : explicit AST_CHAINED(
17 : const long long unsigned nodeId, const SourceLocation &srcLoc,
18 : const std::shared_ptr<AST> &base,
19 : const std::vector<std::shared_ptr<AST>> &operations) noexcept
20 0 : : AST{nodeId, AST_TYPE::CHAIN, srcLoc}, base_{base},
21 0 : operations_{operations} {}
22 :
23 0 : [[nodiscard]] const std::shared_ptr<AST> &base() const noexcept {
24 0 : return base_;
25 0 : }
26 :
27 : [[nodiscard]] const std::vector<std::shared_ptr<AST>> &
28 0 : operations() const noexcept {
29 0 : return operations_;
30 0 : }
31 :
32 : [[nodiscard]] std::expected<std::string, Error>
33 0 : accept(const PrintTree &visitor) const noexcept override {
34 0 : return visitor.visit(this);
35 0 : }
36 :
37 : [[nodiscard]] std::expected<bool, Error>
38 0 : accept(const ValidateTree &visitor) const noexcept override {
39 0 : return visitor.visit(this);
40 0 : }
41 :
42 : [[nodiscard]] std::expected<std::monostate, Error>
43 0 : accept(const FillSemanticInfo &visitor) const noexcept override {
44 0 : return visitor.visit(this);
45 0 : }
46 :
47 : [[nodiscard]] std::expected<std::shared_ptr<Type>, Error>
48 0 : accept(const TypeAnalysis &visitor) const noexcept override {
49 0 : return visitor.visit(this);
50 0 : }
51 :
52 : [[nodiscard]] std::expected<std::monostate, Error>
53 0 : accept(const Monomorphize &visitor) const noexcept override {
54 0 : return visitor.visit(this);
55 0 : }
56 :
57 : [[nodiscard]] std::expected<std::shared_ptr<llvm::Value>, Error>
58 0 : accept(const CodeGeneration &visitor) const noexcept override {
59 0 : return visitor.visit(this);
60 0 : }
61 : };
62 :
63 : } // namespace nicole
64 :
65 : #endif // AST_H
|