il = new InstructionList();
il.append(new GETSTATIC(out));
il.append(new NEW(cp.addClass("java.lang.StringBuffer")));
il.append(InstructionConstants.DUP);
il.append(new PUSH(cp, "Result: "));
il.append(new INVOKESPECIAL(cp.addMethodref("java.lang.StringBuffer",
"<init>",
"(Ljava/lang/String;)V")));
il.append(new ILOAD(0));
il.append(new INVOKEVIRTUAL(cp.addMethodref("java.lang.StringBuffer",
"append",
"(I)Ljava/lang/StringBuffer;")));
il.append(new INVOKEVIRTUAL(cp.addMethodref("java.lang.StringBuffer",
"toString",
"()Ljava/lang/String;")));
il.append(new INVOKEVIRTUAL(cp.addMethodref("java.io.PrintStream",
"println",
"(Ljava/lang/String;)V")));
il.append(new PUSH(cp, 0));
il.append(InstructionConstants.IRETURN); // Reuse objects, if possible
method = new MethodGen(ACC_STATIC | ACC_PRIVATE | ACC_FINAL,
Type.INT, args, argv,
"_writeInt", class_name, il, cp);
method.setMaxStack(4);
class_gen.addMethod(method.getMethod());
/* public <init> -- constructor
*/
il.dispose(); // Dispose instruction handles for better memory utilization
il = new InstructionList();
il.append(new ALOAD(0)); // Push `this'
il.append(new INVOKESPECIAL(cp.addMethodref("java.lang.Object",
"<init>", "()V")));
il.append(new RETURN());
method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, null,
"<init>", class_name, il, cp);
method.setMaxStack(1);
class_gen.addMethod(method.getMethod());
/* class initializer
*/
il.dispose(); // Dispose instruction handles for better memory utilization
il = new InstructionList();
il.append(new NEW(cp.addClass("java.io.BufferedReader")));
il.append(InstructionConstants.DUP);
il.append(new NEW(cp.addClass("java.io.InputStreamReader")));
il.append(InstructionConstants.DUP);
il.append(new GETSTATIC(cp.addFieldref("java.lang.System", "in",
"Ljava/io/InputStream;")));
il.append(new INVOKESPECIAL(cp.addMethodref("java.io.InputStreamReader",
"<init>", "(Ljava/io/InputStream;)V")));
il.append(new INVOKESPECIAL(cp.addMethodref("java.io.BufferedReader",
"<init>", "(Ljava/io/Reader;)V")));
il.append(new PUTSTATIC(_in));
il.append(InstructionConstants.RETURN); // Reuse instruction constants
method = new MethodGen(ACC_STATIC, Type.VOID, Type.NO_ARGS, null,