Line data Source code
1 : #ifndef VARIABLE_H
2 : #define VARIABLE_H
3 :
4 : #include "../symbol.h"
5 : #include "../typeTable/types/type.h"
6 : #include <expected>
7 : #include <llvm/IR/Instructions.h>
8 : #include <llvm/IR/Value.h>
9 : #include <memory>
10 : #include <string>
11 :
12 : namespace nicole {
13 :
14 : class Variable final : public Symbol {
15 : private:
16 : mutable std::shared_ptr<Type> type_;
17 : mutable std::shared_ptr<llvm::Value> value_;
18 : mutable std::shared_ptr<llvm::AllocaInst> address_;
19 :
20 : public:
21 : explicit Variable(const std::string &id, const std::shared_ptr<Type> &type,
22 : const std::shared_ptr<llvm::Value> &value) noexcept
23 0 : : Symbol{id}, type_{type}, value_{value} {}
24 :
25 0 : [[nodiscard]] const std::shared_ptr<Type> &type() const noexcept {
26 0 : return type_;
27 0 : }
28 :
29 0 : [[nodiscard]] const std::shared_ptr<llvm::Value> &value() const noexcept {
30 0 : return value_;
31 0 : }
32 :
33 : [[nodiscard]] const std::shared_ptr<llvm::AllocaInst> &
34 0 : address() const noexcept {
35 0 : return address_;
36 0 : }
37 :
38 0 : void setType(const std::shared_ptr<Type> &type) const noexcept {
39 0 : type_ = type;
40 0 : }
41 : };
42 :
43 : } // namespace nicole
44 :
45 : #endif
|