Line data Source code
1 : #ifndef CONST_TYPE_H
2 : #define CONST_TYPE_H
3 :
4 : #include "../type.h"
5 : #include <memory>
6 : #include <string>
7 :
8 : namespace nicole {
9 :
10 : class ConstType final : public Type {
11 : private:
12 : std::shared_ptr<Type> baseType_;
13 :
14 : public:
15 : explicit ConstType(const std::shared_ptr<Type> &baseType) noexcept
16 0 : : baseType_{baseType} {}
17 :
18 0 : [[nodiscard]] const std::shared_ptr<Type> &baseType() const noexcept {
19 0 : return baseType_;
20 0 : }
21 :
22 0 : [[nodiscard]] std::string toString() const noexcept override {
23 0 : return "const " + baseType_->toString();
24 0 : }
25 : };
26 :
27 : } // namespace nicole
28 :
29 : #endif
|