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