Changeset d318a18 for src/SynTree/GcTracer.h
- Timestamp:
- Jul 18, 2018, 5:18:29 PM (6 years ago)
- Branches:
- new-env
- Children:
- eff03a94
- Parents:
- 5c14030
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/GcTracer.h
r5c14030 rd318a18 25 25 #include "Common/GC.h" 26 26 #include "Common/PassVisitor.h" 27 28 class Expression; 27 #include "ResolvExpr/TypeEnvironment.h" 29 28 30 29 /// Implements `trace` method for syntax nodes … … 34 33 public: 35 34 GcTracer( const GC& gc ) : gc(gc) {} 35 36 template<typename... Args> 37 void traceAll(Args&... args) { ::traceAll(gc, args...); } 36 38 37 39 // mark node and children … … 151 153 maybeAccept( type->baseUnion, *visitor ); 152 154 } 155 156 private: 157 void visit( const ResolvExpr::TypeEnvironment::Classes* c ) { 158 typedef ResolvExpr::TypeEnvironment::Classes C; 159 // trace all parent classes, short-circuiting at one traced 160 while ( gc.notrace_mark( c ) && c->get_mode() != C::BASE ) { c = c->get_base(); } 161 } 162 163 void visit( const ResolvExpr::TypeEnvironment::Bindings* b ) { 164 typedef ResolvExpr::TypeEnvironment::Bindings B; 165 166 while ( true ) { 167 if ( ! gc.notrace_mark( b ) ) return; // short-circuit if already traced 168 169 if ( b->get_mode() == B::BASE ) break; // break if this is a base map 170 171 if ( b->get_mode() != B::REM ) { // trace bound intermediate elements 172 maybeAccept( b->get_val().type, *visitor ); 173 } 174 175 b = b->get_base(); 176 } 177 178 // trace bound elements in base binding 179 b->for_each( [&](interned_string, const ResolvExpr::BoundType& bound) { 180 maybeAccept( bound.type, *visitor ); // trace bound elements 181 } ); 182 } 183 184 public: 185 void visit( const ResolvExpr::TypeEnvironment& env ) { 186 visit( env.classes ); 187 visit( env.bindings ); 188 } 153 189 }; 154 190
Note: See TracChangeset
for help on using the changeset viewer.