public JMethodDeclaration getInitStageMethod() { JBlock statements = new JBlock(null, new JStatement[0], null); FilterContent filter = filterInfo.filter;      List paramList = filter.getParams(); JExpression[] paramArray; if (paramList == null || paramList.size() == 0) paramArray = new JExpression[0]; else paramArray = (JExpression[])paramList.toArray(new JExpression[0]);   statements.addStatement (new JExpressionStatement(null, new JMethodCallExpression (null, new JThisExpression(null), filter.getInit().getName(), paramArray), null));  if (filterInfo.isTwoStage()) {  JBlock body = (JBlock)ObjectDeepCloner.deepCopy (filter.getInitWork().getBody());   statements.addStatement (makeForLoop(receiveCode(filter, filter.getInputType(), generatedVariables), generatedVariables.exeIndex, new JIntLiteral(filterInfo.peek)));   statements.addStatement(body);  if (isSimple()) { statements.addStatement (new JExpressionStatement(null, (new JAssignmentExpression (null, new JLocalVariableExpression (null, generatedVariables.simpleIndex), new JIntLiteral(-1))), null)); } }  if (initFire - 1 > 0) {    if (filterInfo.bottomPeek > 0) { statements.addStatement (makeForLoop(receiveCode(filter, filter.getInputType(), generatedVariables), generatedVariables.exeIndex, new JIntLiteral(filterInfo.bottomPeek))); }   statements.addStatement(generateInitWorkLoop (filter, generatedVariables)); }    if (filterInfo.remaining > 0) { statements.addStatement (makeForLoop(receiveCode(filter, filter.getInputType(), generatedVariables), generatedVariables.exeIndex, new JIntLiteral(filterInfo.remaining))); }  if (SpaceTimeBackend.FILTER_DEBUG_MODE) { statements.addStatement (new SIRPrintStatement(null, new JStringLiteral(null, filter.getName() + " Starting Steady-State"), null)); }  return new JMethodDeclaration(null, at.dms.kjc.Constants.ACC_PUBLIC, CStdType.Void, initStage + uniqueID, JFormalParameter.EMPTY, CClassType.EMPTY, statements, null, null); }
public abstract JMethodDeclaration getInitStageMethod();
    public JMethodDeclaration getInitStageMethod()     {	JBlock statements = new JBlock(null, new JStatement[0], null);	FilterContent filter = filterInfo.filter;		//create the call to the init function		//create the params list, for some reason 	//calling toArray() on the list breaks a later pass	List paramList = filter.getParams();	JExpression[] paramArray;	if (paramList == null || paramList.size() == 0)	    paramArray = new JExpression[0];	else	    paramArray = (JExpression[])paramList.toArray(new JExpression[0]);		//add the call to the init function	statements.addStatement	    (new 	     JExpressionStatement(null,				  new JMethodCallExpression				  (null,				   new JThisExpression(null),				   filter.getInit().getName(),				   paramArray),				  null));	//add the call to initWork	if (filterInfo.isTwoStage()) {	    //FilterContent two = filter;	    JBlock body = 		(JBlock)ObjectDeepCloner.deepCopy		(filter.getInitWork().getBody());	    //add the code to receive the items into the buffer	    statements.addStatement		(makeForLoop(receiveCode(filter, filter.getInputType(), 					 generatedVariables),			     generatedVariables.exeIndex,			     new JIntLiteral(filterInfo.peek)));	    	    //now inline the init work body	    statements.addStatement(body);	    //if a simple filter, reset the simpleIndex	    if (isSimple()) {		statements.addStatement		    (new JExpressionStatement(null,					      (new JAssignmentExpression					       (null,						new JLocalVariableExpression						(null, generatedVariables.simpleIndex),						new JIntLiteral(-1))), null));	    }	}		if (initFire - 1 > 0) {	//add the code to collect enough data necessary to fire the 	//work function for the first time	    	    if (filterInfo.bottomPeek > 0) {		statements.addStatement		    (makeForLoop(receiveCode(filter, filter.getInputType(),					     generatedVariables),				 generatedVariables.exeIndex,				 new JIntLiteral(filterInfo.bottomPeek)));	    }	    	    //add the calls for the work function in the initialization stage	    statements.addStatement(generateInitWorkLoop				    (filter, generatedVariables));	}	//add the code to collect all data produced by the upstream filter 	//but not consumed by this filter in the initialization stage	if (filterInfo.remaining > 0) {	   statements.addStatement		(makeForLoop(receiveCode(filter, filter.getInputType(),					 generatedVariables),			     generatedVariables.exeIndex,			     new JIntLiteral(filterInfo.remaining))); 	}	if (SpaceTimeBackend.FILTER_DEBUG_MODE) {	    statements.addStatement		(new SIRPrintStatement(null,				       new JStringLiteral(null, filter.getName() + " Starting Steady-State"),				       null));	}		return new JMethodDeclaration(null, at.dms.kjc.Constants.ACC_PUBLIC,				      CStdType.Void,				      initStage + uniqueID,				      JFormalParameter.EMPTY,				      CClassType.EMPTY,				      statements,				      null,				      null);     }