gov.llnl.babel.backend.c
Class StubSource

java.lang.Object
  extended by gov.llnl.babel.backend.c.StubSource

public class StubSource
extends java.lang.Object

Class StubSource generates an C Backend stub source file to a language writer output stream. The constructor takes a language writer stream and method generateCode generates intermediate object representation for the specified symbol to the output stream. The language writer output stream is not closed by this object.


Constructor Summary
StubSource(LanguageWriterForC writer, Context context)
          Create a StubSource object that will write symbol information to the provided output writer stream.
 
Method Summary
 void generateCode(Symbol symbol)
          Write C stub source information for the provided symbol to the language writer output stream provided in the constructor.
static void generateCode(Symbol symbol, LanguageWriterForC writer, Context context)
          This is a convenience utility function that writes the C client stub source information into the provided language writer output stream.
static void generateGetExternals(Class cls, LanguageWriterForC writer, Context context)
           
static void generateMethodStubBody(LanguageWriterForC writer, Context context, SymbolID id, boolean isInterface, Method method)
           
static void generateSingleMethodStub(LanguageWriterForC writer, Context context, SymbolID id, boolean isInterface, Method method, boolean writeComment)
          Generate a single method implementation for the methods in the interface or class.
 void generateSupers(java.util.Collection methods, Class cls)
          This function is designed to generate stubs to the super functions available in this Impl files.
static void generateSupers(java.util.Collection methods, Class cls, LanguageWriterForC writer, Context context)
          This is a convenience utility function specifically for the generation of super "Stub" functions in the Impl files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StubSource

public StubSource(LanguageWriterForC writer,
                  Context context)
Create a StubSource object that will write symbol information to the provided output writer stream.

Parameters:
writer - the output writer to which the header will be written. This will not be closed.
Method Detail

generateCode

public static void generateCode(Symbol symbol,
                                LanguageWriterForC writer,
                                Context context)
                         throws CodeGenerationException
This is a convenience utility function that writes the C client stub source information into the provided language writer output stream. The output stream is not closed on exit. A code generation exception is thrown if an error is detected.

Parameters:
symbol - the Symbol whose stub source is being written.
writer - the output writer to which the stub source will be written. This will not be closed.
Throws:
CodeGenerationException - this is a catch all exception. It can be caused by I/O trouble or violations of the data type invariants.

generateSupers

public static void generateSupers(java.util.Collection methods,
                                  Class cls,
                                  LanguageWriterForC writer,
                                  Context context)
                           throws CodeGenerationException
This is a convenience utility function specifically for the generation of super "Stub" functions in the Impl files. The output stream is not closed on exit. A code generation exception is thrown if an error is detected.

Parameters:
methods - is a collection of super methods to be generated.
writer - the output writer to which the stub source will be written. This will not be closed.
cls - The class in which these supers are to be generated
Throws:
CodeGenerationException - this is a catch all exception. It can be caused by I/O trouble or violations of the data type invariants.

generateGetExternals

public static void generateGetExternals(Class cls,
                                        LanguageWriterForC writer,
                                        Context context)
                                 throws CodeGenerationException
Throws:
CodeGenerationException

generateCode

public void generateCode(Symbol symbol)
                  throws CodeGenerationException
Write C stub source information for the provided symbol to the language writer output stream provided in the constructor. This method does not close the language writer output stream and may be called for more than one symbol (although the generated source may not be valid input for the C compiler). A code generation exception is generated if an error is detected. No code is generated for enumerated and package symbols.

Parameters:
symbol - the Symbol whose stub source is being written.
Throws:
CodeGenerationException - this is a catch all exception. It can be caused by I/O trouble or violations of the data type invariants.

generateSupers

public void generateSupers(java.util.Collection methods,
                           Class cls)
                    throws CodeGenerationException
This function is designed to generate stubs to the super functions available in this Impl files. These stubs are generated IN the Impl file. This method does not close the language writer output stream A code generation exception is generated if an error is detected. No code is generated for enumerated and package symbols.

Parameters:
methods - A collection of methods to write out.
Throws:
CodeGenerationException - this is a catch all exception. It can be caused by I/O trouble or violations of the data type invariants.

generateMethodStubBody

public static void generateMethodStubBody(LanguageWriterForC writer,
                                          Context context,
                                          SymbolID id,
                                          boolean isInterface,
                                          Method method)
                                   throws CodeGenerationException
Throws:
CodeGenerationException

generateSingleMethodStub

public static void generateSingleMethodStub(LanguageWriterForC writer,
                                            Context context,
                                            SymbolID id,
                                            boolean isInterface,
                                            Method method,
                                            boolean writeComment)
                                     throws CodeGenerationException
Generate a single method implementation for the methods in the interface or class. This method will also generate the constructor and cast functions.

Throws:
CodeGenerationException