diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-11 15:57:20 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-11 15:57:20 +0000 |
commit | c83c8f224e66d7e21e30546bae308ac5fd52677e (patch) | |
tree | 9a15588353036cf2fccfbfb99bf934b3d1f3cbef /c_compiler/include/declaration.hpp | |
parent | e065e781448b86eeeca0152f735649ea2a2edbb6 (diff) | |
download | Compiler-c83c8f224e66d7e21e30546bae308ac5fd52677e.tar.gz Compiler-c83c8f224e66d7e21e30546bae308ac5fd52677e.zip |
Added shared_ptr for less memory leaks
Diffstat (limited to 'c_compiler/include/declaration.hpp')
-rw-r--r-- | c_compiler/include/declaration.hpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/c_compiler/include/declaration.hpp b/c_compiler/include/declaration.hpp index 5780bd9..08fd641 100644 --- a/c_compiler/include/declaration.hpp +++ b/c_compiler/include/declaration.hpp @@ -3,16 +3,24 @@ #include "node.hpp" +#include <memory> + class Expression; +class Type; +class Declaration; + +typedef std::shared_ptr<Expression> ExpressionPtr; +typedef std::shared_ptr<Type> TypePtr; +typedef std::shared_ptr<Declaration> DeclarationPtr; class Declaration : public Node { private: - Type* type; + TypePtr type; std::string id; - Expression* init; - Declaration* next_decl; - Declaration* list_next_decl; + ExpressionPtr init; + DeclarationPtr next_decl; + DeclarationPtr list_next_decl; public: Declaration(const std::string& _id = "", Expression* _init = nullptr); @@ -26,8 +34,8 @@ public: void setType(Type* _type); - Declaration* getNext() const; - Declaration* getNextListItem() const; + DeclarationPtr getNext() const; + DeclarationPtr getNextListItem() const; std::string getId() const; std::string getType() const; }; |