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