Changeset 24de7b1 for src/Common/GC.h


Ignore:
Timestamp:
Apr 16, 2018, 3:21:17 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
new-env, with_gc
Children:
fb97252f
Parents:
6f81db3
Message:

Fix more missing visits in GcTracer?, add cycle detection back in, ensure mark isn't broken by defaulted GC_Object copy and assign

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/GC.h

    r6f81db3 r24de7b1  
    1818#include <vector>
    1919
    20 class GC_Traceable;
    2120class GC_Object;
    2221class BaseSyntaxNode;
     
    3029
    3130        /// Traces a traceable object
    32         const GC& operator<< (const GC_Traceable*) const;
     31        const GC& operator<< (const GC_Object*) const;
    3332
    3433        /// Adds a new object to garbage collection
     
    111110}
    112111
    113 /// Class that is traced by the GC, but not managed by it
    114 class GC_Traceable {
     112/// Class that is managed by the GC
     113class GC_Object {
    115114        friend class GC;
    116115protected:
    117116        mutable bool mark;
    118117
     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
    119132        /// override to trace any child objects
    120133        virtual void trace(const GC&) const {}
    121 };
    122 
    123 /// Class that is managed by the GC
    124 class GC_Object : public GC_Traceable {
    125         friend class GC;
    126 protected:
    127         virtual ~GC_Object() {}
    128 public:
    129         GC_Object();
    130134};
    131135
Note: See TracChangeset for help on using the changeset viewer.