public void appendOutputString(ExpressionProgram prog, int myIndex, StringBuffer buffer) { // The ExpressionCommand occurs in the program prog at the index indicated by myIndex. // Add a print string representation of the sub-expression represented by this command // (including any previous commands in the program that generate data used by this // command). int upper = prog.extent(myIndex - 1); buffer.append("sum("); buffer.append(sumVar.getName()); buffer.append(", "); prog.appendOutputString(myIndex - 1 - upper, buffer); buffer.append(", "); prog.appendOutputString(myIndex - 1, buffer); buffer.append(", "); buffer.append(sumExpr.toString()); buffer.append(")"); }