Line data Source code
1 : #ifndef AST_THIS_H
2 : #define AST_THIS_H
3 :
4 : #include "../../../tables/typeTable/types/userTypes/userType.h"
5 : #include "../ast.h"
6 : #include <memory>
7 :
8 : namespace nicole {
9 :
10 : class AST_THIS final : public AST {
11 : private:
12 : mutable std::shared_ptr<UserType> userType_{nullptr};
13 :
14 : public:
15 : explicit AST_THIS(const long long unsigned nodeId,
16 : const SourceLocation &srcLoc) noexcept
17 0 : : AST{nodeId, AST_TYPE::THIS, srcLoc} {}
18 :
19 0 : ~AST_THIS() noexcept = default;
20 :
21 0 : [[nodiscard]] const std::shared_ptr<UserType> &userType() const noexcept {
22 0 : return userType_;
23 0 : }
24 :
25 0 : void setUserType(const std::shared_ptr<UserType> &userType) const noexcept {
26 0 : userType_ = userType;
27 0 : }
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 // AST_H
|