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/statement.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/statement.hpp')
-rw-r--r-- | c_compiler/include/statement.hpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/c_compiler/include/statement.hpp b/c_compiler/include/statement.hpp index b5f7e9c..d491b68 100644 --- a/c_compiler/include/statement.hpp +++ b/c_compiler/include/statement.hpp @@ -3,13 +3,20 @@ #include "node.hpp" +#include <memory> + class Declaration; class Expression; +class Statement; + +typedef std::shared_ptr<Declaration> DeclarationPtr; +typedef std::shared_ptr<Expression> ExpressionPtr; +typedef std::shared_ptr<Statement> StatementPtr; class Statement : public Node { protected: - Statement* next_statement; + StatementPtr next_statement; public: Statement(Statement* statement = nullptr); @@ -26,8 +33,8 @@ public: class CompoundStatement : public Statement { protected: - Declaration* m_decl; - Statement* m_statement; + DeclarationPtr m_decl; + StatementPtr m_statement; public: CompoundStatement(Declaration* decl = nullptr, Statement* statement = nullptr); @@ -43,8 +50,8 @@ public: class SelectionStatement : public Statement { protected: - Statement* m_if; - Statement* m_else; + StatementPtr m_if; + StatementPtr m_else; public: SelectionStatement(Statement* _if = nullptr, Statement* _else = nullptr); @@ -58,7 +65,7 @@ public: class ExpressionStatement : public Statement { protected: - Expression* m_expr; + ExpressionPtr m_expr; public: ExpressionStatement(Expression* expr = nullptr); @@ -72,7 +79,7 @@ public: class JumpStatement : public Statement { protected: - Expression* m_expr; + ExpressionPtr m_expr; public: JumpStatement(Expression* expr = nullptr); @@ -86,7 +93,7 @@ public: class IterationStatement : public Statement { protected: - Statement* m_statement; + StatementPtr m_statement; public: IterationStatement(Statement* statement); |