partitions.add(new Integer(count+1));
partitions.add(count+1);
        public Object visitPipeline(SIRPipeline self,                                    JFieldDeclaration[] fields,                                    JMethodDeclaration[] methods,                                    JMethodDeclaration init) {            // first visit children            self = (SIRPipeline)super.visitPipeline(self, fields, methods, init);            // 1. DETERMINE WHERE TO FUSE:            // walk through pipeline, determining who should be fused.            // We fuse anyone where the result will be stateless.            // This requires:            // 1. original filters are stateless            // 2. only the first filter can peek (otherwise peek            //    buffer becomes state.)            ArrayList<Integer> partitions = new ArrayList<Integer>();            // position of start of current fusion segment            int pos = 0;             // length of current fusion segment            int count = 0;            while (pos+count < self.size()) {                SIRStream child = self.get(pos+count);                if (canFuse(child, count)) {                    // keep looping if the partition has room to grow                    if (pos+count+1 < self.size()) {                        count++;                        continue;                    }                } else if (count > 0) {                    // this one should not be included in the count                    count--;                }                // otherwise, should not fuse with child, or we are at                // the end of the pipeline, so conclude current set of                // partitions                partitions.add(new Integer(count+1));                // if we indicated some fusion, first make sure that                // these children have been fused into filters                if (count>0) {                    for (int i=pos; i<pos+count+1; i++) {                        fuseChild(self, i);                    }                }                // reset counters                pos = pos+count+1;                count = 0;            }            // 2. PERFORM PIPELINE FUSION:            if (partitions.size()==1) {                // if we are fusing everything, call fuse all due to the                // bad interface in FusePipe                SIRPipeline wrapper = FuseAll.fuse(self);                // should get back a wrapper with a single component                SIRStream child = wrapper.get(0);                // setup parent-child relationship                child.setParent(wrapper.getParent());                // check that fusion product stateless                checkState((SIRFilter)child);                return child;            } else {                // fuse the pipeline according to the recorded partitions                int[] partitionArr = new int[partitions.size()];                for (int i=0; i<partitionArr.length; i++) {                    partitionArr[i] = partitions.get(i).intValue();                }                PartitionGroup pg = PartitionGroup.createFromArray(partitionArr);                // return ourself, since we still have more than one                // component (we were mutated by the fuser)                FusePipe.fuse(self, pg);                // check that products were stateless                for (int i=0; i<partitionArr.length; i++) {                    // if we fused something here                    if (partitionArr[i]>1) {                        checkState((SIRFilter)self.get(i));                    }                }                return self;            }        }