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