Line data Source code
1 : #ifndef AST_CONSTRUCTOR_DECL_H
2 : #define AST_CONSTRUCTOR_DECL_H
3 :
4 : #include "../../../tables/typeTable/types/userTypes/genericParameter.h"
5 : #include "../functions/ast_parametrizedSubritineDecl.h"
6 : #include "ast_super.h"
7 : #include <memory>
8 :
9 : namespace nicole {
10 :
11 : class AST_CONSTRUCTOR_DECL final : public AST_PARAMETRIZED_SUBRUTINE_DECL {
12 : private:
13 : mutable std::vector<GenericParameter> generics_;
14 : std::shared_ptr<AST_SUPER> super_;
15 :
16 : public:
17 : explicit AST_CONSTRUCTOR_DECL(const long long unsigned nodeId,
18 : const SourceLocation &srcLoc,
19 : const std::string &id,
20 : const std::vector<GenericParameter> &generics,
21 : const Parameters ¶ms,
22 : const std::shared_ptr<AST_SUPER> super,
23 : const std::shared_ptr<Type> &returnType,
24 : const std::shared_ptr<AST_BODY> &body) noexcept
25 0 : : AST_PARAMETRIZED_SUBRUTINE_DECL(nodeId, AST_TYPE::CONSTRUCTOR_DECL,
26 0 : srcLoc, id, params, returnType, body),
27 0 : generics_{generics}, super_{super} {}
28 :
29 0 : [[nodiscard]] const std::vector<GenericParameter> &generics() const noexcept {
30 0 : return generics_;
31 0 : }
32 :
33 0 : [[nodiscard]] const std::shared_ptr<AST_SUPER> &super() const noexcept {
34 0 : return super_;
35 0 : }
36 :
37 : void
38 0 : setGenerics(const std::vector<GenericParameter> &generics) const noexcept {
39 0 : generics_ = generics;
40 0 : }
41 :
42 : [[nodiscard]] std::expected<std::string, Error>
43 0 : accept(const PrintTree &visitor) const noexcept override {
44 0 : return visitor.visit(this);
45 0 : }
46 :
47 : [[nodiscard]] std::expected<bool, Error>
48 0 : accept(const ValidateTree &visitor) const noexcept override {
49 0 : return visitor.visit(this);
50 0 : }
51 :
52 : [[nodiscard]] std::expected<std::monostate, Error>
53 0 : accept(const FillSemanticInfo &visitor) const noexcept override {
54 0 : return visitor.visit(this);
55 0 : }
56 :
57 : [[nodiscard]] std::expected<std::shared_ptr<Type>, Error>
58 0 : accept(const TypeAnalysis &visitor) const noexcept override {
59 0 : return visitor.visit(this);
60 0 : }
61 :
62 : [[nodiscard]] std::expected<std::monostate, Error>
63 0 : accept(const Monomorphize &visitor) const noexcept override {
64 0 : return visitor.visit(this);
65 0 : }
66 :
67 : [[nodiscard]] std::expected<std::shared_ptr<llvm::Value>, Error>
68 0 : accept(const CodeGeneration &visitor) const noexcept override {
69 0 : return visitor.visit(this);
70 0 : }
71 : };
72 :
73 : } // namespace nicole
74 :
75 : #endif
|