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