mirror of https://github.com/aamine/cbc
* net/loveruby/cflat/compiler/Compiler.java: implement -o option.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4004 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
parent
9ea468d3db
commit
50d605a369
|
@ -1,3 +1,7 @@
|
||||||
|
Sun Sep 7 08:36:28 2008 Minero Aoki <aamine@loveruby.net>
|
||||||
|
|
||||||
|
* net/loveruby/cflat/compiler/Compiler.java: implement -o option.
|
||||||
|
|
||||||
Sun Sep 7 08:06:38 2008 Minero Aoki <aamine@loveruby.net>
|
Sun Sep 7 08:06:38 2008 Minero Aoki <aamine@loveruby.net>
|
||||||
|
|
||||||
* net/loveruby/cflat/compiler/CodeGenerator.java: split compileLHS
|
* net/loveruby/cflat/compiler/CodeGenerator.java: split compileLHS
|
||||||
|
|
|
@ -49,12 +49,14 @@ public class Compiler {
|
||||||
class Options {
|
class Options {
|
||||||
public String mode;
|
public String mode;
|
||||||
public String inputFile;
|
public String inputFile;
|
||||||
//public String outputFile;
|
public String outputFile;
|
||||||
public boolean verbose;
|
public boolean verbose;
|
||||||
public boolean debugParser;
|
public boolean debugParser;
|
||||||
//public boolean debugBuild;
|
//public boolean debugBuild;
|
||||||
public TypeTable typeTable;
|
public TypeTable typeTable;
|
||||||
public LibraryLoader loader;
|
public LibraryLoader loader;
|
||||||
|
//public List asOpts; // List<String>
|
||||||
|
//public List ldOpts; // List<String>
|
||||||
//public List ldArgs; // List<LdArg>
|
//public List ldArgs; // List<LdArg>
|
||||||
|
|
||||||
public boolean isMode(String m) {
|
public boolean isMode(String m) {
|
||||||
|
@ -90,11 +92,10 @@ public class Compiler {
|
||||||
else if (arg.equals("--debug-parser")) {
|
else if (arg.equals("--debug-parser")) {
|
||||||
opts.debugParser = true;
|
opts.debugParser = true;
|
||||||
}
|
}
|
||||||
// FIXME: generic options
|
else if (arg.startsWith("-o")) {
|
||||||
//else if (arg.startsWith("-o"))
|
opts.outputFile = getOptArg(arg, it);
|
||||||
//else if (arg.equals("--type-model"))
|
}
|
||||||
// FIXME: compile options
|
// FIXME: compile options
|
||||||
//else if (arg.equals("-g"))
|
|
||||||
//else if (arg.equals("-fPIC"))
|
//else if (arg.equals("-fPIC"))
|
||||||
//else if (arg.startsWith("-O"))
|
//else if (arg.startsWith("-O"))
|
||||||
// FIXME: assemble options
|
// FIXME: assemble options
|
||||||
|
@ -142,6 +143,7 @@ public class Compiler {
|
||||||
out.println(" -S Generates an assembly source.");
|
out.println(" -S Generates an assembly source.");
|
||||||
out.println(" -c Generates an object file.");
|
out.println(" -c Generates an object file.");
|
||||||
out.println(" -I PATH Adds import file loading path.");
|
out.println(" -I PATH Adds import file loading path.");
|
||||||
|
out.println(" -o PATH Places output in file PATH.");
|
||||||
out.println(" --help Prints this message and quit.");
|
out.println(" --help Prints this message and quit.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,19 +208,15 @@ public class Compiler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String asm = CodeGenerator.generate(ast, opts.typeTable, errorHandler);
|
String asm = CodeGenerator.generate(ast, opts.typeTable, errorHandler);
|
||||||
writeFile(asmFileName(opts.inputFile), asm);
|
writeFile(asmFileName(opts), asm);
|
||||||
if (opts.isMode("-S")) {
|
if (opts.isMode("-S")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
assemble(asmFileName(opts.inputFile),
|
assemble(asmFileName(opts), objFileName(opts), opts);
|
||||||
objFileName(opts.inputFile),
|
|
||||||
opts);
|
|
||||||
if (opts.isMode("-c")) {
|
if (opts.isMode("-c")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
link(objFileName(opts.inputFile),
|
link(objFileName(opts), exeFileName(opts), opts);
|
||||||
exeFileName(opts.inputFile),
|
|
||||||
opts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void dumpTokenList(Token t, PrintStream s) {
|
protected void dumpTokenList(Token t, PrintStream s) {
|
||||||
|
@ -392,16 +390,22 @@ public class Compiler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String asmFileName(String orgPath) {
|
protected String asmFileName(Options opts) {
|
||||||
return baseName(orgPath, true) + ".s";
|
return opts.isMode("-S") && opts.outputFile != null
|
||||||
|
? opts.outputFile
|
||||||
|
: baseName(opts.inputFile, true) + ".s";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String objFileName(String orgPath) {
|
protected String objFileName(Options opts) {
|
||||||
return baseName(orgPath, true) + ".o";
|
return opts.isMode("-c") && opts.outputFile != null
|
||||||
|
? opts.outputFile
|
||||||
|
: baseName(opts.inputFile, true) + ".o";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String exeFileName(String orgPath) {
|
protected String exeFileName(Options opts) {
|
||||||
return baseName(orgPath, true);
|
return opts.outputFile != null
|
||||||
|
? opts.outputFile
|
||||||
|
: baseName(opts.inputFile, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String baseName(String path) {
|
protected String baseName(String path) {
|
||||||
|
|
Loading…
Reference in New Issue