Line data Source code
1 : #ifndef AST_ELSE_IF_H
2 : #define AST_ELSE_IF_H
3 :
4 : #include "../statements/ast_body.h"
5 : #include "ast_condition.h"
6 : #include <memory>
7 :
8 : namespace nicole {
9 :
10 : class AST_ELSE_IF : public AST {
11 : private:
12 : std::shared_ptr<AST_CONDITION> condition_;
13 : std::shared_ptr<AST_BODY> body_;
14 :
15 : public:
16 : explicit AST_ELSE_IF(const long long unsigned nodeId,
17 : const SourceLocation &srcLoc,
18 : const std::shared_ptr<AST_CONDITION> &condition,
19 : const std::shared_ptr<AST_BODY> &body) noexcept
20 2 : : AST(nodeId, AST_TYPE::ELSE_IF, srcLoc), condition_{condition},
21 2 : body_{body} {}
22 :
23 : [[nodiscard]] const std::shared_ptr<AST_CONDITION> &
24 9 : condition() const noexcept {
25 9 : return condition_;
26 9 : }
27 :
28 9 : [[nodiscard]] const std::shared_ptr<AST_BODY> &body() const noexcept {
29 9 : return body_;
30 9 : }
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
|