- assert(node != NULL);
-
- // Check that we have all the inputs we need for this effect.
- // If not, we end the phase here right away; the other side
- // of the input chain will eventually come and pick the effect up.
- assert(incoming_links.count(node) == 1);
- std::vector<Effect *> deps = incoming_links[node];
- assert(node->num_inputs() == deps.size());
- if (!deps.empty()) {
- bool have_all_deps = true;
+ if (!effects_todo_this_phase.empty()) {
+ // OK, we have more to do this phase.
+ Effect *effect = effects_todo_this_phase.top();
+ effects_todo_this_phase.pop();
+
+ // This should currently only happen for effects that are phase outputs,
+ // and we throw those out separately below.
+ assert(completed_effects.count(effect) == 0);
+
+ this_phase_effects.push_back(effect);
+ completed_effects.insert(effect);
+
+ // Find all the dependencies of this effect, and add them to the stack.
+ assert(incoming_links.count(effect) == 1);
+ std::vector<Effect *> deps = incoming_links[effect];
+ assert(effect->num_inputs() == deps.size());