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