Java 类org.objectweb.asm.jbfc.BFCompiler 实例源码

项目:asm-legacy-svn-clone    文件:jbfc.java   
public static void main(final String[] args) throws IOException {
    if (args.length < 2) {
        System.out
                .println("Usage: jbfc [-v] <bf program file> <java class name>");
        return;
    }

    boolean verbose = false;
    String fileName = null;
    String className = null;
    for (int i = 0; i < args.length; i++) {
        if ("-v".equals(args[i])) {
            verbose = true;
        } else {
            fileName = args[i];
            className = args[i + 1];
            break;
        }
    }

    FileReader r = new FileReader(fileName);

    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
    BFCompiler c = new BFCompiler();
    if (verbose) {
        c.compile(r, className, fileName, new TraceClassVisitor(cw,
                new PrintWriter(System.out)));
    } else {
        c.compile(r, className, fileName, cw);
    }

    r.close();

    FileOutputStream os = new FileOutputStream(className + ".class");
    os.write(cw.toByteArray());
    os.flush();
    os.close();
}
项目:ow2-asm    文件:jbfc.java   
public static void main(final String[] args) throws IOException {
    if (args.length < 2) {
        System.out
                .println("Usage: jbfc [-v] <bf program file> <java class name>");
        return;
    }

    boolean verbose = false;
    String fileName = null;
    String className = null;
    for (int i = 0; i < args.length; i++) {
        if ("-v".equals(args[i])) {
            verbose = true;
        } else {
            fileName = args[i];
            className = args[i + 1];
            break;
        }
    }

    FileReader r = new FileReader(fileName);

    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
    BFCompiler c = new BFCompiler();
    if (verbose) {
        c.compile(r, className, fileName, new TraceClassVisitor(cw,
                new PrintWriter(System.out)));
    } else {
        c.compile(r, className, fileName, cw);
    }

    r.close();

    FileOutputStream os = new FileOutputStream(className + ".class");
    os.write(cw.toByteArray());
    os.flush();
    os.close();
}
项目:objectweb-asm-4.0    文件:jbfc.java   
public static void main(final String[] args) throws IOException {
    if (args.length < 2) {
        System.out.println("Usage: jbfc [-v] <bf program file> <java class name>");
        return;
    }

    boolean verbose = false;
    String fileName = null;
    String className = null;
    for (int i = 0; i < args.length; i++) {
        if ("-v".equals(args[i])) {
            verbose = true;
        } else {
            fileName = args[i];
            className = args[i + 1];
            break;
        }
    }

    FileReader r = new FileReader(fileName);

    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
    BFCompiler c = new BFCompiler();
    if (verbose) {
        c.compile(r, className, fileName, new TraceClassVisitor(cw,
                new PrintWriter(System.out)));
    } else {
        c.compile(r, className, fileName, cw);
    }

    r.close();

    FileOutputStream os = new FileOutputStream(className + ".class");
    os.write(cw.toByteArray());
    os.flush();
    os.close();
}