fix preproc tags

git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4303 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
Minero Aoki 2009-06-27 16:09:22 +00:00
parent 4ec1db3eea
commit f54cfaab75
3 changed files with 17 additions and 6 deletions

View File

@ -144,12 +144,15 @@ public class Compiler {
return opts.codeGenerator(errorHandler).generate(ir);
}
// #@@range/assemble{
public void assemble(String srcPath, String destPath,
Options opts) throws IPCException {
opts.assembler(errorHandler)
.assemble(srcPath, destPath, opts.asOptions());
}
// #@@}
// #@@range/link{
public void link(Options opts) throws IPCException {
if (! opts.isGeneratingSharedLibrary()) {
generateExecutable(opts);
@ -158,16 +161,21 @@ public class Compiler {
generateSharedLibrary(opts);
}
}
// #@@}
// #@@range/generateExecutable{
public void generateExecutable(Options opts) throws IPCException {
opts.linker(errorHandler).generateExecutable(
opts.ldArgs(), opts.exeFileName(), opts.ldOptions());
}
// #@@}
// #@@range/generateSharedLibrary{
public void generateSharedLibrary(Options opts) throws IPCException {
opts.linker(errorHandler).generateSharedLibrary(
opts.ldArgs(), opts.soFileName(), opts.ldOptions());
}
// #@@}
private void writeFile(String path, String str) throws FileException {
if (path.equals("-")) {

View File

@ -12,6 +12,7 @@ class GNUAssembler implements Assembler {
this.errorHandler = h;
}
// #@@range/assemble{
public void assemble(String srcPath, String destPath,
AssemblerOptions opts) throws IPCException {
List<String> cmd = new ArrayList<String>();
@ -22,4 +23,5 @@ class GNUAssembler implements Assembler {
cmd.add(srcPath);
CommandUtils.invoke(cmd, errorHandler, opts.verbose);
}
// #@@}
}

View File

@ -152,6 +152,7 @@ public class CodeGenerator implements net.loveruby.cflat.sysdep.CodeGenerator,
if (ir.isFunctionDefined()) {
generateTextSection(file, ir.definedFunctions());
}
// #@@range/generateAssemblyCode_last{
if (ir.isCommonSymbolDefined()) {
generateCommonSymbols(file, ir.definedCommonSymbols());
}
@ -159,6 +160,7 @@ public class CodeGenerator implements net.loveruby.cflat.sysdep.CodeGenerator,
PICThunk(file, GOTBaseReg());
}
return file;
// #@@}
}
// #@@}
@ -266,19 +268,18 @@ public class CodeGenerator implements net.loveruby.cflat.sysdep.CodeGenerator,
// PIC/PIE related constants and codes
//
// #@@range/pic_methods{
static private final Symbol GOT =
new NamedSymbol("_GLOBAL_OFFSET_TABLE_");
// #@@range/loadGOT{
static private final Symbol GOT = new NamedSymbol("_GLOBAL_OFFSET_TABLE_");
private void loadGOTBaseAddress(AssemblyCode file, Register reg) {
file.call(PICThunkSymbol(reg));
file.add(imm(GOT), reg);
}
// #@@}
private Register GOTBaseReg() {
return bx();
}
// #@@}
// #@@range/pic_symbols{
private Symbol globalGOTSymbol(Symbol base) {
@ -294,16 +295,16 @@ public class CodeGenerator implements net.loveruby.cflat.sysdep.CodeGenerator,
}
// #@@}
// #@@range/pic_thunk_helper{
// #@@range/PICThunkSymbol{
private Symbol PICThunkSymbol(Register reg) {
return new NamedSymbol("__i686.get_pc_thunk." + reg.baseName());
}
// #@@}
static private final String
PICThunkSectionFlags = SectionFlag_allocatable
+ SectionFlag_executable
+ SectionFlag_sectiongroup;
// #@@}
/**
* Output PIC thunk.