Line data Source code
1 : #ifndef AST_ASSIGNMENT_H
2 : #define AST_ASSIGNMENT_H
3 :
4 : #include "../../../lexicalAnalysis/token.h"
5 : #include "../ast.h"
6 : #include <string>
7 :
8 : namespace nicole {
9 :
10 : class AST_ASSIGNMENT final : public AST {
11 : private:
12 : Token op_;
13 : std::shared_ptr<AST> left_;
14 : std::shared_ptr<AST> value_;
15 :
16 : public:
17 : explicit AST_ASSIGNMENT(const long long unsigned nodeId, const SourceLocation &srcLoc, const Token &op,
18 : const std::shared_ptr<AST> &left,
19 : const std::shared_ptr<AST> &value) noexcept
20 1 : : AST(nodeId, AST_TYPE::ASSIGNMENT, srcLoc), op_{op}, left_{left}, value_{value} {
21 1 : }
22 :
23 9 : [[nodiscard]] const Token &op() const noexcept { return op_; }
24 :
25 9 : [[nodiscard]] const std::shared_ptr<AST> &left() const noexcept {
26 9 : return left_;
27 9 : }
28 :
29 18 : [[nodiscard]] const std::shared_ptr<AST> &value() const noexcept {
30 18 : return value_;
31 18 : }
32 :
33 : [[nodiscard]] std::expected<std::string, Error>
34 0 : accept(const PrintTree &visitor) const noexcept override {
35 0 : return visitor.visit(this);
36 0 : }
37 :
38 : [[nodiscard]] std::expected<bool, Error>
39 0 : accept(const ValidateTree &visitor) const noexcept override {
40 0 : return visitor.visit(this);
41 0 : }
42 :
43 : [[nodiscard]] std::expected<std::monostate, Error>
44 0 : accept(const FillSemanticInfo &visitor) const noexcept override {
45 0 : return visitor.visit(this);
46 0 : }
47 :
48 : [[nodiscard]] std::expected<std::shared_ptr<Type>, Error>
49 0 : accept(const TypeAnalysis &visitor) const noexcept override {
50 0 : return visitor.visit(this);
51 0 : }
52 :
53 : [[nodiscard]] std::expected<std::monostate, Error>
54 0 : accept(const Monomorphize &visitor) const noexcept override {
55 0 : return visitor.visit(this);
56 0 : }
57 :
58 : [[nodiscard]] std::expected<std::shared_ptr<llvm::Value>, Error>
59 0 : accept(const CodeGeneration &visitor) const noexcept override {
60 0 : return visitor.visit(this);
61 0 : }
62 : };
63 :
64 : } // namespace nicole
65 :
66 : #endif
|