#ifndef __NASAL_GC_H__ #define __NASAL_GC_H__ struct gc_unit { // collected: If gc collected this item,it'll be set to true.Otherwise it is false. // elem: Item that this unit stores // refcnt: Reference counter bool collected; nasal_scalar elem; int refcnt; gc_unit() { collected=true; //elem=0; refcnt=0; return; } gc_unit(const gc_unit& tmp) { collected=tmp.collected; //elem=tmp.elem; refcnt=tmp.refcnt; return; } }; class gc_manager { private: // free_space list is used to store space that is not in use. std::list free_space; std::vector memory; public: gc_manager() { memory.clear(); free_space.clear(); return; } ~gc_manager() { memory.clear(); free_space.clear(); return; } void gc_init() { // this function must be called in class nasal_runtime // before running any codes std::vector tmp_vec; memory.clear(); memory.swap(tmp_vec); // clear the memory capacity by using tmp_vec.~vector() free_space.clear(); return; } void gc_scanner() { int memory_size=memory.size(); for(int i=0;i> [Gc] collected "; prt_hex(i); std::cout<<"."<> [Gc] fatal error: unexpected memory place "; prt_hex(place); std::cout<<" ."<> [Gc] fatal error: unexpected memory place "; prt_hex(place); std::cout<<" ."<> [Gc] memory size:"<> [Gc] memory capacity:"<> [Gc] memory usage: "<