Line data Source code
1 : #ifndef AST_METHOD_CALL_H
2 : #define AST_METHOD_CALL_H
3 :
4 : #include "../../../tables/typeTable/types/type.h"
5 : #include "../ast.h"
6 : #include <memory>
7 : #include <vector>
8 :
9 : namespace nicole {
10 :
11 : class AST_METHOD_CALL : public AST {
12 : private:
13 : std::string id_;
14 : mutable std::vector<std::shared_ptr<Type>> replaceOfGenerics_;
15 : std::vector<std::shared_ptr<AST>> parameters_;
16 :
17 : public:
18 : explicit AST_METHOD_CALL(
19 : const long long unsigned nodeId, const SourceLocation &srcLoc,
20 : const std::string &id,
21 : const std::vector<std::shared_ptr<Type>> &replaceOfGenerics,
22 : const std::vector<std::shared_ptr<AST>> ¶meters) noexcept
23 0 : : AST(nodeId, AST_TYPE::METHOD_CALL, srcLoc), id_{id},
24 0 : replaceOfGenerics_{replaceOfGenerics}, parameters_{parameters} {}
25 :
26 0 : [[nodiscard]] const std::string &id() const noexcept { return id_; }
27 :
28 : [[nodiscard]] const std::vector<std::shared_ptr<Type>> &
29 0 : replaceOfGenerics() const noexcept {
30 0 : return replaceOfGenerics_;
31 0 : }
32 :
33 : [[nodiscard]] const std::vector<std::shared_ptr<AST>> &
34 0 : parameters() const noexcept {
35 0 : return parameters_;
36 0 : }
37 :
38 : [[nodiscard]] std::expected<std::monostate, Error>
39 : setGenericReplacement(const std::size_t pos,
40 0 : const std::shared_ptr<Type> &type) const noexcept {
41 0 : if (pos >= replaceOfGenerics_.size()) {
42 0 : return createError(
43 0 : ERROR_TYPE::TYPE,
44 0 : "trying to access a invalid position in a replacement list");
45 0 : }
46 0 : replaceOfGenerics_[pos] = type;
47 0 : return {};
48 0 : }
49 :
50 : [[nodiscard]] std::expected<std::string, Error>
51 0 : accept(const PrintTree &visitor) const noexcept override {
52 0 : return visitor.visit(this);
53 0 : }
54 :
55 : [[nodiscard]] std::expected<bool, Error>
56 0 : accept(const ValidateTree &visitor) const noexcept override {
57 0 : return visitor.visit(this);
58 0 : }
59 :
60 : [[nodiscard]] std::expected<std::monostate, Error>
61 0 : accept(const FillSemanticInfo &visitor) const noexcept override {
62 0 : return visitor.visit(this);
63 0 : }
64 :
65 : [[nodiscard]] std::expected<std::shared_ptr<Type>, Error>
66 0 : accept(const TypeAnalysis &visitor) const noexcept override {
67 0 : return visitor.visit(this);
68 0 : }
69 :
70 : [[nodiscard]] std::expected<std::monostate, Error>
71 0 : accept(const Monomorphize &visitor) const noexcept override {
72 0 : return visitor.visit(this);
73 0 : }
74 :
75 : [[nodiscard]] std::expected<std::shared_ptr<llvm::Value>, Error>
76 0 : accept(const CodeGeneration &visitor) const noexcept override {
77 0 : return visitor.visit(this);
78 0 : }
79 : };
80 :
81 : } // namespace nicole
82 :
83 : #endif
|