org.dellroad.jc.cgen
Class JCObjectGenerator

java.lang.Object
  extended byorg.dellroad.jc.cgen.JCObjectGenerator
All Implemented Interfaces:
ObjectGenerator

public class JCObjectGenerator
extends Object
implements ObjectGenerator

The default JC object file generator class. This class uses a CodeGenerator to generate C source and header files, then compiles them into ELF object files using GCC.

The generated source files are expected to contain initial double-slash comment lines with @dep_header tags for each required header file and @dep_class tags for each class file on which the generated source depends.


Constructor Summary
JCObjectGenerator()
          Instantiate an object with an instance of SootCodeGenerator using a custom SourceLocator as the underlying source file generator, and use system properties to determine where source and object files go, whether to be verbose, and what MethodOptimizer to use.
JCObjectGenerator(CodeGenerator codeGenerator, String sourcePath, boolean verbose, boolean debugSymbols, boolean sourcesOnly, boolean force)
          Instantiate an object using the supplied configuration.
 
Method Summary
 File cFile(String className, int i)
          Return the file that contains the C source code for the class.
 void generateObject(String className, ClassfileFinder finder, File objectFile)
          Generate object file using analysis via Soot.
 File hFile(String className, int i)
          Return the file that contains the C header source for the class.
 boolean objectIsValid(String className, ClassfileFinder finder, File objectFile)
          Determine if an ELF object file is valid for the named class and all other classes (available through the provided finder) on which the object file may depend.
 long parseHash(String s)
          Parse an unsigned 8 byte hex value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JCObjectGenerator

public JCObjectGenerator()
Instantiate an object with an instance of SootCodeGenerator using a custom SourceLocator as the underlying source file generator, and use system properties to determine where source and object files go, whether to be verbose, and what MethodOptimizer to use. This constructor should only be used when JC is the JVM.


JCObjectGenerator

public JCObjectGenerator(CodeGenerator codeGenerator,
                         String sourcePath,
                         boolean verbose,
                         boolean debugSymbols,
                         boolean sourcesOnly,
                         boolean force)
Instantiate an object using the supplied configuration.

Parameters:
codeGenerator - Object that can generate JC C source code.
sourcePath - Search path for C source and header files. First component of path is where newly generated files go.
verbose - Whether to print verbose output to standard error
debugSymbols - Whether to compile with the -g flag.
sourcesOnly - If true generate sources only, don't compile them into ELF objects.
Method Detail

generateObject

public void generateObject(String className,
                           ClassfileFinder finder,
                           File objectFile)
                    throws Exception
Generate object file using analysis via Soot.

This method is synchronized because Soot is not reentrant.

Specified by:
generateObject in interface ObjectGenerator
Parameters:
className - Class name (with slashes, not dots)
finder - Object capable of retrieving class files
objectFile - Where to put resulting ELF object
Throws:
Exception

objectIsValid

public boolean objectIsValid(String className,
                             ClassfileFinder finder,
                             File objectFile)
                      throws Exception
Description copied from interface: ObjectGenerator
Determine if an ELF object file is valid for the named class and all other classes (available through the provided finder) on which the object file may depend.

Specified by:
objectIsValid in interface ObjectGenerator
Parameters:
className - Class name (with slashes, not dots)
finder - Class finder capable of retrieving class files
objectFile - Where to put resulting ELF object
Throws:
Exception

cFile

public File cFile(String className,
                  int i)
Return the file that contains the C source code for the class.


hFile

public File hFile(String className,
                  int i)
Return the file that contains the C header source for the class.


parseHash

public long parseHash(String s)
               throws NumberFormatException
Parse an unsigned 8 byte hex value. This method is required because Long.parseLong() only parses signed values.

Throws:
NumberFormatException