model_server/subsystem/src/Entity.cxx
//
// Goes down from this entity to mark all code that is actually referenced.
// We stop going down and go sideways when we find something already marked 
// as live, both to protect against infinite recursion and to improve speed
// if this is done several times with different top-level functions.
Goes down from this entity to mark all code that is actually referenced.
We stop going down and go sideways when we find something already marked
as live, both to protect against infinite recursion and to improve speed
if this is done several times with different top-level functions.
Goes down from this entity to mark all code that is actually referenced . We stop going down and go sideways when we find something already marked as live both to protect against infinite recursion and to improve speed if this is done several times with different top - level functions .
void Entity::find_live_code(struct weight *w, int nw, int depth, FILE* dump_file) {
   Initialize(Entity::find_live_code);
   if (dump_file) {
      OSapi_fprintf(dump_file, "%2d:%.*s ", depth, depth, "==============================");
      dump_refs_and_weights(dump_file, *allentities);
   }
   ddKind my_kind = my_sym.get_kind();
   refs_and_weights_iter it(rw);
   ref_and_weight* ref;
   while (ref = it.next()) {
      if (w[ref->weight].outgoing) {
	 EntityPtr ent = EntityPtr((*allentities)[ref->targ_ref]);
	 symbolPtr ent_sym = ent->my_sym;
	 if (!ent->isundead ||
	     (ref->weight == AUS_FCALL &&
	      strstr(ent_sym.get_name(), "::~") &&
	      ent_sym->get_attribute(VIRT_ATT, 1))) {
	    if (ref->weight == AUS_FCALL ||
		(my_kind == DD_VAR_DECL && ent_sym.get_kind() == DD_FUNC_DECL)) {
	       symbolArr relateds;
	       ent_sym.get_overrides(relateds, false);
	       ent->add_operator_delete(relateds);
	       ent_sym.get_base_dtors(relateds);
	       ent->find_member_dtors(relateds);
	       if (relateds.size() == 0) {
		  relateds.insert_last(ent_sym);
	       }
	       symbolPtr related;
	       ForEachS(related, relateds) {
		  EntityPtr rel_ent = allentities->item(related);
		  if (rel_ent && !rel_ent->isundead) {
		     rel_ent->isundead = 1;
		     if (dump_file) {
			OSapi_fprintf(dump_file, "+");
		     }
		     rel_ent->find_live_code(w, nw, depth + 1, dump_file);
		  }
	       }
	    }
	    else {
	       ent->isundead = 1;
	       if (dump_file) {
		  OSapi_fprintf(dump_file, " ");
	       }
	       ent->find_live_code(w, nw, depth+1, dump_file);
	    }
	 }
      }
   }
}
void Entity :: find_live_code ( struct weight * w , int nw , int depth , FILE * dump_file ) { Initialize ( Entity :: find_live_code ) ; if ( dump_file ) { OSapi_fprintf ( dump_file , " " , depth , depth , " " ) ; dump_refs_and_weights ( dump_file , * allentities ) ; } ddKind my_kind = my_sym . get_kind ( ) ; refs_and_weights_iter it ( rw ) ; ref_and_weight * ref ; while ( ref = it . next ( ) ) { if ( w [ ref -> weight ] . outgoing ) { EntityPtr ent = EntityPtr ( ( * allentities ) [ ref -> targ_ref ] ) ; symbolPtr ent_sym = ent -> my_sym ; if ( ! ent -> isundead || ( ref -> weight == AUS_FCALL && strstr ( ent_sym . get_name ( ) , " " ) && ent_sym -> get_attribute ( VIRT_ATT , 1 ) ) ) { if ( ref -> weight == AUS_FCALL || ( my_kind == DD_VAR_DECL && ent_sym . get_kind ( ) == DD_FUNC_DECL ) ) { symbolArr relateds ; ent_sym . get_overrides ( relateds , false ) ; ent -> add_operator_delete ( relateds ) ; ent_sym . get_base_dtors ( relateds ) ; ent -> find_member_dtors ( relateds ) ; if ( relateds . size ( ) == 0 ) { relateds . insert_last ( ent_sym ) ; } symbolPtr related ; ForEachS ( related , relateds ) { EntityPtr rel_ent = allentities -> item ( related ) ; if ( rel_ent && ! rel_ent -> isundead ) { rel_ent -> isundead = 1 ; if ( dump_file ) { OSapi_fprintf ( dump_file , " " ) ; } rel_ent -> find_live_code ( w , nw , depth + 1 , dump_file ) ; } } } else { ent -> isundead = 1 ; if ( dump_file ) { OSapi_fprintf ( dump_file , " " ) ; } ent -> find_live_code ( w , nw , depth + 1 , dump_file ) ; } } } } }
Goes down from this entity to mark all code that is actually referenced.
Goes down from this entity to mark all code that is actually referenced .
// The condition following the "||" handles the case where there // is a direct reference to a virtual destructor that was earlier // processed only by virtue of being a member of a base class of // a destroyed object. // The condition following the "||" handles the case of a ptr-to-mbr // variable that is initialized with "ent"; dereferencing this variable // does a virtual dispatch, so the code below must be executed in this // case.