Line data Source code
1 : #ifndef AST_SUBRUTINE_DECL_H
2 : #define AST_SUBRUTINE_DECL_H
3 :
4 : #include "../../../tables/typeTable/types/type.h"
5 : #include "../statements/ast_body.h"
6 : #include <memory>
7 : #include <string>
8 :
9 : namespace nicole {
10 :
11 : class AST_SUBRUTINE_DECL : public AST {
12 : private:
13 : std::string id_;
14 : mutable std::shared_ptr<Type> returnType_;
15 : mutable std::shared_ptr<AST_BODY> body_;
16 :
17 : public:
18 : explicit AST_SUBRUTINE_DECL(const long long unsigned nodeId,
19 : const AST_TYPE type, const SourceLocation &srcLoc,
20 : const std::string &id,
21 : const std::shared_ptr<Type> &returnType,
22 : const std::shared_ptr<AST_BODY> &body) noexcept
23 0 : : AST(nodeId, type, srcLoc), id_{id}, returnType_{returnType},
24 0 : body_{body} {}
25 :
26 0 : [[nodiscard]] const std::string &id() const noexcept { return id_; }
27 :
28 0 : [[nodiscard]] const std::shared_ptr<Type> &returnType() const noexcept {
29 0 : return returnType_;
30 0 : }
31 :
32 0 : [[nodiscard]] const std::shared_ptr<AST_BODY> &body() const noexcept {
33 0 : return body_;
34 0 : }
35 :
36 0 : void setReturnType(const std::shared_ptr<Type> &type) const noexcept {
37 0 : returnType_ = type;
38 0 : }
39 : };
40 :
41 : } // namespace nicole
42 :
43 : #endif
|