diff options
author | David Robillard <d@drobilla.net> | 2009-06-19 03:33:41 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-06-19 03:33:41 +0000 |
commit | 38b50b89bc638fe5d94bc6523c574504a5ef368d (patch) | |
tree | 26a4040749843ea8f3eed769d068f838229630ae /gc.cpp | |
parent | 855456a9d98c5c27bb2b00bab4018630598117fa (diff) | |
download | resp-38b50b89bc638fe5d94bc6523c574504a5ef368d.tar.gz resp-38b50b89bc638fe5d94bc6523c574504a5ef368d.tar.bz2 resp-38b50b89bc638fe5d94bc6523c574504a5ef368d.zip |
Factor out memory/GC related things from AST to Object.
git-svn-id: http://svn.drobilla.net/resp/tuplr@124 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'gc.cpp')
-rw-r--r-- | gc.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -25,18 +25,18 @@ void* GC::alloc(size_t size) { void* ret = malloc(size); - _heap.push_back((AST*)ret); + _heap.push_back((Object*)ret); return ret; } inline void -mark(CEnv& cenv, const AST* ast) +mark(CEnv& cenv, const Object* obj) { - if (!ast || ast->used) + if (!obj || obj->used) return; - ast->used = true; - const ATuple* tup = ast->to<const ATuple*>(); + obj->used = true; + const ATuple* tup = dynamic_cast<const ATuple*>(obj); if (tup) { FOREACH(ATuple::const_iterator, i, *tup) { mark(cenv, *i); @@ -57,10 +57,10 @@ GC::collect(CEnv& cenv, const Roots& roots) if ((*i)->used) { (*i)->used = false; } else { - AType* t = (*i)->to<AType*>(); + AType* t = dynamic_cast<AType*>(*i); // Don't delete types that are keys in the current type substitution if (!t || cenv.tsubst.find(t) == cenv.tsubst.end()) { - (*i)->~AST(); + (*i)->~Object(); free(*i); _heap.erase(i); } |