public static JStatement makeForLoop(JStatement body, JExpression count, JVariableDefinition loopIndex) {  loopIndex.setInitializer(new JIntLiteral(0));  JVariableDeclarationStatement varDecl = new JVariableDeclarationStatement(null, loopIndex, null);   if (count instanceof JIntLiteral) { int intCount = ((JIntLiteral)count).intValue(); if (intCount<=0) {       return (KjcOptions.rstream ? (JStatement)(new JEmptyStatement()) : (JStatement)varDecl); } else if (intCount==1) {   return (KjcOptions.rstream ? body : new JBlock(null, new JStatement[] { varDecl, body }, null)); } }   JExpression cond = new JRelationalExpression(null, Constants.OPE_LT, new JLocalVariableExpression(null, loopIndex), count);  JStatement incr = new JExpressionStatement(null, new JPostfixExpression(null, Constants. OPE_POSTINC, new JLocalVariableExpression(null, loopIndex)), null);  JavaStyleComment comments[] = null;   if (getForLoopCallers) { String caller; { Throwable tracer = new Throwable(); tracer.fillInStackTrace(); caller = "ClusterExecution.makeForLoop(" + count + "): " + tracer.getStackTrace()[1].toString(); } JavaStyleComment comment = new JavaStyleComment(caller, true, false, false); comments = new JavaStyleComment[] {comment};   System.err.println(caller);  }   JStatement forStatement = new JForStatement( null,   (KjcOptions.rstream ? (JStatement) varDecl : (JStatement) new JEmptyStatement(null, null)), cond, incr, body, comments);  JStatement[] statements = {varDecl, forStatement};  return (KjcOptions.rstream ? forStatement : new JBlock(null, statements, null));
public static JStatement makeForLoop(JStatement body, int count) { return makeForLoop(body, new JIntLiteral(count));
    public static JStatement makeForLoop(JStatement body, JExpression count, JVariableDefinition loopIndex) {        // make sure we start counting from 0        loopIndex.setInitializer(new JIntLiteral(0));        // make a declaration statement for our new variable        JVariableDeclarationStatement varDecl =            new JVariableDeclarationStatement(null, loopIndex, null);        // avoid loops for certain loop bounds        if (count instanceof JIntLiteral) {            int intCount = ((JIntLiteral)count).intValue();            if (intCount<=0) {                // if the count isn't positive, return the variable                // decl.  Return this rather than an empty statement                // in case some later code depends on the value of                // this variable on loop exit.  However, rstream seems                // not to need the VarDecl, so return only an empty                // statement there.                return (KjcOptions.rstream ? (JStatement)(new JEmptyStatement()) : (JStatement)varDecl);            } else if (intCount==1) {                // if the count is one, then return the decl and the                // body (but rstream doesn't need the decl).                return (KjcOptions.rstream ? body :                        new JBlock(null, new JStatement[] { varDecl, body }, null));            }        }        // make a test if our variable is less than <pre>count</pre>        JExpression cond =             new JRelationalExpression(null,                                      Constants.OPE_LT,                                      new JLocalVariableExpression(null, loopIndex),                                      count);        // make an increment for <pre>var</pre>        JStatement incr =             new JExpressionStatement(null,                                     new JPostfixExpression(null,                                                            Constants.                                                            OPE_POSTINC,                                                            new JLocalVariableExpression(null, loopIndex)),                                     null);        JavaStyleComment comments[] = null;                // debugging: print caller, and insert caller as comment on returned for loop        if (getForLoopCallers) {            String caller;            {                Throwable tracer = new Throwable();                tracer.fillInStackTrace();                caller = "ClusterExecution.makeForLoop(" + count + "): "                        + tracer.getStackTrace()[1].toString();            }            JavaStyleComment comment = new JavaStyleComment(caller, true, false, false);            comments = new JavaStyleComment[] {comment};            // should have separate flag for this...            System.err.println(caller);        }                // make the for statement        JStatement forStatement =             new JForStatement(/* tokref */ null,                              //for rstream put the vardecl in the init of the for loop                              /* init */ (KjcOptions.rstream ? (JStatement) varDecl :                                           (JStatement) new JEmptyStatement(null, null)),                              cond,                              incr,                              body,                              comments);        // return the block        JStatement[] statements = {varDecl, forStatement};        //return just the for statement for rstream        return (KjcOptions.rstream ? forStatement : new JBlock(null, statements, null));    }