org.dellroad.jc.cgen
Class SootCodeGenerator

java.lang.Object
  extended byorg.dellroad.jc.cgen.SootCodeGenerator
All Implemented Interfaces:
CodeGenerator

public class SootCodeGenerator
extends Object
implements CodeGenerator

JC's default source file generator. This class generates C code by first analyzing class files using the Soot framework, and then converting byte code into C statements using the various other helper classes in this package.


Constructor Summary
SootCodeGenerator(SourceLocator sourceLocator, MethodOptimizer optimizer, boolean includeLineNumbers)
          Instantiate.
 
Method Summary
 void genC(String className, OutputStream output)
          Generate the C source file for the class using the Soot framework.
 void generateC(String className, ClassfileFinder finder, OutputStream output)
          Wrapper for genC() that handles properly configuring Soot to find class files.
 void generateH(String className, ClassfileFinder finder, OutputStream output)
          Wrapper for genH() that handles properly configuring Soot to find class files.
 void genH(String className, OutputStream output)
          Generate the C header file for the class using the Soot framework.
 void reset()
          Reset Soot.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SootCodeGenerator

public SootCodeGenerator(SourceLocator sourceLocator,
                         MethodOptimizer optimizer,
                         boolean includeLineNumbers)
Instantiate. Only one instance of this class should be used at a time.

Parameters:
sourceLocator - How Soot should retrieve class files, or null in which case the finder parameter to generateC() and generateH() must be an instance of SearchpathFinder.
optimizer - Object for optimizing method bodies, or null to use the default.
Method Detail

reset

public void reset()
Reset Soot.

Specified by:
reset in interface CodeGenerator

generateH

public final void generateH(String className,
                            ClassfileFinder finder,
                            OutputStream output)
                     throws Exception
Wrapper for genH() that handles properly configuring Soot to find class files.

Specified by:
generateH in interface CodeGenerator
Parameters:
className - name of the class who's header file we're generating
finder - a way to acquire Java class files
output - where to write the generated header file to
Throws:
Exception

generateC

public final void generateC(String className,
                            ClassfileFinder finder,
                            OutputStream output)
                     throws Exception
Wrapper for genC() that handles properly configuring Soot to find class files.

Specified by:
generateC in interface CodeGenerator
Parameters:
className - name of the class who's C file we're generating
finder - a way to acquire Java class files
output - where to write the generated C file to
Throws:
Exception

genH

public void genH(String className,
                 OutputStream output)
          throws Exception
Generate the C header file for the class using the Soot framework. Subclasses should override this method instead of # generateH().

Parameters:
className - Class name with dots instead of slashes
Throws:
Exception

genC

public void genC(String className,
                 OutputStream output)
          throws Exception
Generate the C source file for the class using the Soot framework. Subclasses should override this method instead of generateC().

Parameters:
className - Class name with dots instead of slashes
Throws:
Exception