-// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL]
+// Copyright 2000-2005 the Contributors, as shown in the revision logs.
+// Licensed under the Apache Public Source License 2.0 ("the License").
+// You may not use this file except in compliance with the License.
package org.ibex.nestedvm;
import org.ibex.nestedvm.util.*;
-// FEATURE: -d option for classfilecompiler (just like javac's -d)
-
public abstract class Compiler implements Registers {
/** The ELF binary being read */
ELF elf;
public static void main(String[] args) throws IOException {
String outfile = null;
+ String outdir = null;
String o = null;
String className = null;
String mipsBinaryFileName = null;
arg++;
if(arg==args.length) usage();
outfile = args[arg];
+ } else if(args[arg].equals("-d")) {
+ arg++;
+ if(arg==args.length) usage();
+ outdir = args[arg];
} else if(args[arg].equals("-outformat")) {
arg++;
if(arg==args.length) usage();
OutputStream os = null;
Compiler comp = null;
if(outformat == null || outformat.equals("class")) {
- if(outfile == null) {
+ if(outfile != null) {
+ os = new FileOutputStream(outfile);
+ comp = new ClassFileCompiler(mipsBinary,className,os);
+ } else if(outdir != null) {
+ File f = new File(outdir);
+ if(!f.isDirectory()) {
+ System.err.println(outdir + " doesn't exist or is not a directory");
+ System.exit(1);
+ }
+ comp = new ClassFileCompiler(mipsBinary,className,f);
+ } else {
System.err.println("Refusing to write a classfile to stdout - use -outfile foo.class");
System.exit(1);
}
- os = new FileOutputStream(outfile);
- comp = new ClassFileCompiler(mipsBinary,className,os);
} else if(outformat.equals("javasource") || outformat .equals("java")) {
w = outfile == null ? new OutputStreamWriter(System.out): new FileWriter(outfile);
comp = new JavaSourceCompiler(mipsBinary,className,w);
"pageSize", "The page size (must be a power of two)",
"totalPages", "Total number of pages (total mem = pageSize*totalPages, must be a power of two)",
"onePage", "One page hack (FIXME: document this better)",
- "lessConstants", "Use less constants at the cost of speed (FIXME: document this better)"
+ "lessConstants", "Use less constants at the cost of speed (FIXME: document this better)",
+ "singleFloat", "Support single precision (32-bit) FP ops only"
};
private Option getOption(String name) {