Trace[] init = new Trace[2]; Trace[] steady = new Trace[2];
ArrayList initTraces=new ArrayList(); ArrayList steadyTraces=new ArrayList(); HashMap[] executionCounts=SIRScheduler.getExecutionCounts(str); UnflatFilter currentFilter=topNodes[0]; TraceNode currentNode=new FilterTraceNode(new FilterContent(currentFilter.filter,executionCounts),0,0); initTraces.add(new Trace(currentNode)); steadyTraces.add(new Trace(currentNode)); int curX=1; int forward=1; while(currentFilter!=null&&currentFilter.outWeights.length>0) { currentFilter=currentFilter.out[0][0].dest; if(currentFilter!=null) { TraceNode newNode=new FilterTraceNode(new FilterContent(currentFilter.filter,executionCounts),curX,0); currentNode.setNext(newNode); currentNode=newNode; if(curX>=rawColumns-1&&forward>0) { if(currentFilter.outWeights.length>0&&currentFilter.out[0][0].dest!=null) { forward=-1; OutputTraceNode out=new OutputTraceNode(new int[]{1}); InputTraceNode in=new InputTraceNode(new int[]{1}); out.setDests(new InputTraceNode[][]{new InputTraceNode[]{in}}); in.setSources(new OutputTraceNode[]{out}); currentNode.setNext(out); currentNode=in; initTraces.add(new Trace(currentNode)); steadyTraces.add(new Trace(currentNode)); } } else if(curX<=0&&forward<0) { if(currentFilter.outWeights.length>0&&currentFilter.out[0][0].dest!=null) { forward=1; OutputTraceNode out=new OutputTraceNode(new int[]{1}); InputTraceNode in=new InputTraceNode(new int[]{1}); out.setDests(new InputTraceNode[][]{new InputTraceNode[]{in}}); in.setSources(new OutputTraceNode[]{out}); currentNode.setNext(out); currentNode=in; initTraces.add(new Trace(currentNode)); steadyTraces.add(new Trace(currentNode)); } } else curX+=forward; } } Trace[] init=new Trace[initTraces.size()]; Trace[] steady=new Trace[steadyTraces.size()]; initTraces.toArray(init); steadyTraces.toArray(steady); for(int i=1;i<init.length;i++) { init[i-1].setEdges(new Trace[]{init[i]}); init[i].setDepends(new Trace[]{init[i-1]}); steady[i-1].setEdges(new Trace[]{steady[i]}); steady[i].setDepends(new Trace[]{steady[i-1]}); }  initTraces=null; steadyTraces=null; executionCounts=null;
    public static void run(SIRStream str,			   JInterfaceDeclaration[] 			   interfaces,			   SIRInterfaceTable[]			   interfaceTables,			   SIRStructure[]			   structs) {	structures = structs;		int rawRows = -1;	int rawColumns = -1;	//set number of columns/rows	rawRows = KjcOptions.raw;	if(KjcOptions.rawcol>-1)	    rawColumns = KjcOptions.rawcol;	else	    rawColumns = KjcOptions.raw;	//create the RawChip	RawChip rawChip = new RawChip(rawRows, rawColumns);	//this must be run now, other pass rely on it...	RenameAll.renameOverAllFilters(str);		// move field initializations into init function	FieldInitMover.moveStreamInitialAssignments(str);			// propagate constants and unroll loop	System.out.println("Running Constant Prop and Unroll...");	ConstantProp.propagateAndUnroll(str);	System.out.println("Done Constant Prop and Unroll...");	// construct stream hierarchy from SIRInitStatements	ConstructSIRTree.doit(str);	//VarDecl Raise to move array assignments up	new VarDeclRaiser().raiseVars(str);	// do constant propagation on fields        if (KjcOptions.nofieldprop) {	} else {	    System.out.println("Running Constant Field Propagation...");	    FieldProp.doPropagate(str);	    System.out.println("Done Constant Field Propagation...");	}	Lifter.liftAggressiveSync(str);       	StreamItDot.printGraph(str, "before.dot");	//jasperln's Stuff	FlattenGraph.flattenGraph(str);	UnflatFilter[] topNodes=FlattenGraph.getTopLevelNodes();	System.out.println("Top Nodes:");	for(int i=0;i<topNodes.length;i++)	    System.out.println(topNodes[i]);	//System.out.println(FlattenGraph.getFilterCount());		//this is here just to test things!!	Trace[] init = new Trace[2];	Trace[] steady = new Trace[2];	//mgordon's stuff	ListIterator initTrav = TraceTraversal.getTraversal(init).listIterator();    	ListIterator steadyTrav = TraceTraversal.getTraversal(steady).listIterator();	//create the raw execution code and switch code for the initialization phase	Rawify.run(initTrav, rawChip, true); 	//create the raw execution code and switch for the steady-state	Rawify.run(initTrav, rawChip, false);	//generate the switch code assembly files...	GenerateSwitchCode.run(rawChip);	//generate the compute code from the SIR	GenerateComputeCode.run(rawChip);	Makefile.generate(rawChip);    }