@@ -144,6 +144,11 @@ void Environment::assemble() { // NOLINT(readability-function-cognitive-complexi
144144 }
145145}
146146
147+ void Environment::clear_dependency_graph () {
148+ dependencies_.clear ();
149+ reactions_.clear ();
150+ }
151+
147152void Environment::build_dependency_graph (Reactor* reactor) {
148153 // obtain dependencies from each contained reactor
149154 for (auto * sub_reactor : reactor->reactors ()) {
@@ -157,23 +162,14 @@ void Environment::build_dependency_graph(Reactor* reactor) {
157162 validate (result.second , " priorities must be unique for all reactions_ of the same reactor" );
158163 }
159164
160- dependencies_.clear (); // TODO: fix
161-
162165 // connect all reactions_ this reaction depends on
163166 for (auto * reaction : reactor->reactions ()) {
164- std::set<BasePort*> dependencies = reaction->dependencies ();
165- for (auto * dependency : dependencies) {
166- if (dependency <= (BasePort*)0x100 ) {
167- std::cout << " FUCK" << std::endl;
168- }
169- while (dependency->has_inward_binding ()) {
170- if (dependency <= (BasePort*)0x100 ) {
171- std::cout << " FUCK" << std::endl;
172- }
173- dependency = dependency->inward_binding ();
167+ for (auto * dependency : reaction->dependencies ()) {
168+ auto * source = dependency;
169+ while (source->has_inward_binding ()) {
170+ source = source->inward_binding ();
174171 }
175- std::cout << " anti deps of: " << dependency->fqn () << " (" << dependency << " )" << std::endl;
176- for (auto * antidependency : dependency->anti_dependencies ()) {
172+ for (auto * antidependency : source->anti_dependencies ()) {
177173 dependencies_.emplace_back (reaction, antidependency);
178174 }
179175 }
0 commit comments