From e93fef76f19b80e44baa07942f72c5af4cee6ffe Mon Sep 17 00:00:00 2001 From: Stefano Sanfilippo Date: Fri, 28 Nov 2014 19:15:36 +0100 Subject: [PATCH] Freeing Function objects before destroying program. --- Nodes.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Nodes.hpp b/Nodes.hpp index e51db20..9e6fd57 100644 --- a/Nodes.hpp +++ b/Nodes.hpp @@ -264,6 +264,8 @@ class Function: public Emittable { public: Function(Id *n, IdList *a, StatementList *b): name(n), args(a), body(b) {} + virtual ~Function() {} + virtual void emit(std::ostream &stream, int indent = 0); private: @@ -274,6 +276,12 @@ private: class Program: public Emittable { public: + virtual ~Program() { + for (Function *f: functions) { + delete f; + } + } + virtual void emit(std::ostream &stream, int indent = 0); void setMain(Main *m) {