Changeset 24de7b1 for src/Common
- Timestamp:
- Apr 16, 2018, 3:21:17 PM (6 years ago)
- Branches:
- new-env, with_gc
- Children:
- fb97252f
- Parents:
- 6f81db3
- Location:
- src/Common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/GC.cc
r6f81db3 r24de7b1 40 40 } 41 41 42 const GC& GC::operator<< (const GC_ Traceable* obj) const {42 const GC& GC::operator<< (const GC_Object* obj) const { 43 43 if( obj ) 44 44 { … … 119 119 } 120 120 121 GC_Object::GC_Object( const GC_Object& ) { 122 GC::get().register_object( this ); 123 } 124 125 GC_Object::GC_Object( GC_Object&& ) { 126 GC::get().register_object( this ); 127 } 128 121 129 // Local Variables: // 122 130 // tab-width: 4 // -
src/Common/GC.h
r6f81db3 r24de7b1 18 18 #include <vector> 19 19 20 class GC_Traceable;21 20 class GC_Object; 22 21 class BaseSyntaxNode; … … 30 29 31 30 /// Traces a traceable object 32 const GC& operator<< (const GC_ Traceable*) const;31 const GC& operator<< (const GC_Object*) const; 33 32 34 33 /// Adds a new object to garbage collection … … 111 110 } 112 111 113 /// Class that is traced by the GC, but not managed by it114 class GC_ Traceable{112 /// Class that is managed by the GC 113 class GC_Object { 115 114 friend class GC; 116 115 protected: 117 116 mutable bool mark; 118 117 118 // Override default constructors to ensure clones are registered and properly marked 119 GC_Object(); 120 121 GC_Object(const GC_Object&); 122 123 GC_Object(GC_Object&&); 124 125 GC_Object& operator= (const GC_Object&) { /* do not assign mark */ return *this; } 126 127 GC_Object& operator= (GC_Object&&) { /* do not assign mark */ return *this; } 128 129 // Ensure subclasses can be deleted by garbage collector 130 virtual ~GC_Object() {} 131 119 132 /// override to trace any child objects 120 133 virtual void trace(const GC&) const {} 121 };122 123 /// Class that is managed by the GC124 class GC_Object : public GC_Traceable {125 friend class GC;126 protected:127 virtual ~GC_Object() {}128 public:129 GC_Object();130 134 }; 131 135
Note: See TracChangeset
for help on using the changeset viewer.