Line data Source code
1 : #ifndef METHOD_H
2 : #define METHOD_H
3 :
4 : #include "../../../../parsingAnalysis/ast/functions/parameters.h"
5 : #include "../../../symbol.h"
6 : #include "genericParameter.h"
7 : #include <memory>
8 :
9 : namespace nicole {
10 :
11 : class AST_BODY;
12 :
13 : class Method final : public Symbol {
14 : private:
15 : mutable std::vector<GenericParameter> generics_;
16 : mutable Parameters params_;
17 : mutable std::shared_ptr<Type> returnType_;
18 : std::shared_ptr<AST_BODY> body_;
19 : bool isVirtual_;
20 : mutable bool isInherited_{false};
21 :
22 : public:
23 : explicit Method(const std::string &id,
24 : const std::vector<GenericParameter> &generics,
25 : const Parameters ¶ms,
26 : const std::shared_ptr<Type> &returnType,
27 : const std::shared_ptr<AST_BODY> &body,
28 : const bool isVirtual) noexcept
29 0 : : Symbol{id}, generics_{generics}, params_{params},
30 0 : returnType_{returnType}, body_{body}, isVirtual_{isVirtual} {}
31 :
32 0 : [[nodiscard]] const std::vector<GenericParameter> &generics() const noexcept {
33 0 : return generics_;
34 0 : }
35 :
36 0 : [[nodiscard]] const Parameters ¶ms() const noexcept { return params_; }
37 :
38 0 : [[nodiscard]] const std::shared_ptr<Type> &returnType() const noexcept {
39 0 : return returnType_;
40 0 : }
41 :
42 0 : [[nodiscard]] const std::shared_ptr<AST_BODY> &body() const noexcept {
43 0 : return body_;
44 0 : }
45 :
46 0 : [[nodiscard]] bool isVirtual() const noexcept { return isVirtual_; }
47 :
48 0 : void setInherit(const bool inherit) const noexcept { isInherited_ = inherit; }
49 :
50 0 : [[nodiscard]] bool isInherited() const noexcept { return isInherited_; }
51 :
52 0 : void setReturnType(const std::shared_ptr<Type> &type) const noexcept {
53 0 : returnType_ = type;
54 0 : }
55 :
56 0 : void setParameters(const Parameters ¶ms) const noexcept {
57 0 : params_ = params;
58 0 : }
59 :
60 : void
61 0 : setGenerics(const std::vector<GenericParameter> &generics) const noexcept {
62 0 : generics_ = generics;
63 0 : }
64 : };
65 :
66 : } // namespace nicole
67 :
68 : #endif
|