pipeline.setInit(SIRStream.makeEmptyInit());
    private void reSIR(SIRContainer parent, FlatNode current,             Set<FlatNode> visited) {        // for filters: keep adding them to current pipeline until something         // other than a filter is found.        // if no current pipeline, start a new pipeline.        if (current.isFilter()) {            SIRPipeline pipeline;            if (!(parent instanceof SIRPipeline)) {                pipeline = new SIRPipeline(parent, "Pipeline" + id++                        + parentSuffix(current.contents));                pipeline.setInit(SIRStream.makeEmptyInit());                parent.add(pipeline);            }            else {                pipeline = (SIRPipeline)parent;            }            //keep adding filters to this pipeline            while (current.isFilter()) {                //make sure we have not added this filter before                assert !(visited.contains(current)) : "Same filter found twice" + current.toString();                //record that we have added this filter                visited.add(current);                List<JExpression> params;                //if its parent does not contain it, just pass null params...                if (parent.indexOf(current.getFilter()) == -1) {                    params = new LinkedList<JExpression>();                 } else {                    params = ((SIRFilter)current.contents).getParams();                }                pipeline.add((SIRFilter)current.contents, params);                ((SIRFilter)current.contents).setParent(parent);                //no outgoing edges: end pipeline.                if (current.ways == 0)                    return;                //assert that there is exactly one outgoing edge of this filter                assert current.ways == 1 && current.edges.length == 1;                current = current.edges[0];            }        }                 // current is not filter, either on entry to reSIR, or after processing        // a number of filters.        if (current.isSplitter()) {          // splitter: 2 cases original parent should tell us          // if this is a top of a splitjoin or bottom of a feedbackloop          //          // If splitter does not have a parent, then we assume that this          // is a splitjoin that has been broken across different dynamic regions          // (rather than a feedbackloop being brofen across dynamic regions)          SIRSplitter splitter = (SIRSplitter)current.contents;          if (splitter.getParent() instanceof SIRSplitJoin                  || splitter.getParent() == null) {              // Splitjoin splitter            // create splitjoin with dummy joiner and recur on branches of split.            SIRSplitJoin splitJoin = new SIRSplitJoin(parent, "SplitJoin" + id++                    + parentSuffix(splitter));            splitJoin.setInit(SIRStream.makeEmptyInit());            //add this splitjoin to the parent!            parent.add(splitJoin);            //make sure we have not seen this splitter            assert !(visited.contains(current)) : "Should not have encountered splitjoin splitter twice.";            //record that we have added this splitter            visited.add(current);            splitJoin.setSplitter((SIRSplitter)current.contents);            //create a dummy joiner for this split join just in case it does not have one            SIRJoiner joiner = SIRJoiner.create(splitJoin, SIRJoinType.NULL,                                                 ((SIRSplitter)current.contents).getWays());            splitJoin.setJoiner(joiner);            for (int i = 0; i < current.edges.length; i++) {                if (current.edges[i] != null) {                    //wrap all parallel splitter edges in a pipeline                    SIRPipeline pipeline = new SIRPipeline(splitJoin, "Pipeline" + id++                             + parentSuffix(current.edges[i].contents));                    pipeline.setInit(SIRStream.makeEmptyInit());                    splitJoin.add(pipeline);                    reSIR(pipeline, current.edges[i], visited);                }                    }            return;          } else {              assert ((SIRSplitter)(current.contents)).getParent() instanceof SIRFeedbackLoop;              // splitter of existing feedback loop.              // bubble up to closest FeedbackLoop parent.              SIRContainer fbloop = parent;              while (!(fbloop instanceof SIRFeedbackLoop)) {                  fbloop = fbloop.getParent();              }              assert fbloop != null;              assert ! visited.contains(current);                            // record that we have added this splitter.              visited.add(current);              ((SIRFeedbackLoop)fbloop).setSplitter((SIRSplitter)current.contents);              assert current.ways == 2 && current.edges[1] != null;              SIRPipeline pipeline = new SIRPipeline(fbloop, "Pipeline" + id++                      + suffix(current.edges[1].contents));              ((SIRFeedbackLoop)fbloop).setLoop(pipeline);              reSIR(pipeline,current.edges[1],visited);              if (current.edges[0] != null) {                  reSIR(((SIRFeedbackLoop)fbloop).getParent(), current.edges[0], visited);              }          }                  } else if (current.isJoiner()) {            if (current.isFeedbackJoiner()) {                if (! (visited.contains(current))) {                    visited.add(current);                    //new feedback loop.  Assume that splitter is in same graph.                    // Set both up now.                    SIRFeedbackLoop fbloop = new SIRFeedbackLoop(parent,"FBLoop" + id++                             + parentSuffix(current.contents));                    SIRFeedbackLoop oldparent = (SIRFeedbackLoop)current.contents.getParent();                    fbloop.setInit(SIRStream.makeEmptyInit());                    fbloop.setDelay(oldparent.getDelay());                    fbloop.setInitPath(oldparent.getInitPath());                    fbloop.setJoiner((SIRJoiner)current.contents);                    parent.add(fbloop);                    assert current.ways == 1 && current.edges[0] != null;                    SIRPipeline pipeline = new SIRPipeline(fbloop, "Pipeline" + id++                            + suffix(current.edges[0].contents));                    fbloop.setBody(pipeline);                    reSIR(pipeline, current.edges[0], visited);                } // else end this recursion at end of loop portion            } else {              // end of existing splitjoin: update joiner and              // reSIR continuation.              if (! visited.contains(current)) {                SIRContainer splitJoin = parent;                while (!(splitJoin instanceof SIRSplitJoin)) {                    splitJoin = splitJoin.getParent();                }                assert splitJoin != null;                // record that we have added this Joiner                visited.add(current);                // first time we are seeing this joiner so set it as the                // joiner and visit the remainder of the graph                ((SIRSplitJoin) splitJoin).setJoiner((SIRJoiner) current.contents);                if (current.ways > 0) {                    assert current.edges.length == 1 && current.ways == 1                    && current.edges[0] != null;                    reSIR(((SIRSplitJoin) splitJoin).getParent(),                            current.edges[0], visited);                }              }            }        } else {            assert current == null;       // not filter, splitter, joiner: terminate recursion.        }        return;    }