gov.llnl.babel.backend.fortran
Class ImplSource

java.lang.Object
  extended by gov.llnl.babel.backend.fortran.ImplSource

public class ImplSource
extends java.lang.Object

This class provides the ability to write a FORTRAN file with a subroutine template for each method the end user has to implement for a sidl class. The class will retain the previous user provided implementation when overwriting a implementation file.


Constructor Summary
ImplSource(LanguageWriterForFortran writer, CodeSplicer splicer, Context context)
          Generate an instance to generate a FORTRAN implementation template.
 
Method Summary
 void addUseForReferences(Method m, SymbolID id)
           
 java.util.Map findCollisions(java.util.Map methodsSeen, Symbol sym)
           
 void generateCode(Class cls)
          Generate the implementation FORTRAN file for a sidl class.
static void generateCode(Class cls, LanguageWriterForFortran writer, CodeSplicer splicer, Context context)
          Generate the implementation FORTRAN file for a sidl class.
 java.lang.String getArgumentDeclaration(Argument a)
          Return the argument declaration, tailored to the specific flavor of FORTRAN.
 java.lang.String getFunctionRetTypeDecl(Argument a, java.lang.String methodName)
          Return the function declaration, tailored to BindC.
static boolean isFortranFunction(Type check, Context context)
          Utility function that checks if we have a fortran function that returns primitve types.
static boolean isInt(java.lang.String s)
           
 void useStatementsForSupers(Method m, SymbolID id)
           
static void useStatementsForSupers(Method m, SymbolID id, LanguageWriterForFortran writer, CodeSplicer splicer, Context context)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImplSource

public ImplSource(LanguageWriterForFortran writer,
                  CodeSplicer splicer,
                  Context context)
           throws java.security.NoSuchAlgorithmException
Generate an instance to generate a FORTRAN implementation template.

Parameters:
writer - the output device to which the FORTRAN implementation should be written.
splicer - this stores the previous implementation when one exists.
Throws:
java.security.NoSuchAlgorithmException - thrown when the JVM has not SHA hash algorithm.
Method Detail

useStatementsForSupers

public static void useStatementsForSupers(Method m,
                                          SymbolID id,
                                          LanguageWriterForFortran writer,
                                          CodeSplicer splicer,
                                          Context context)
                                   throws CodeGenerationException
Throws:
CodeGenerationException

useStatementsForSupers

public void useStatementsForSupers(Method m,
                                   SymbolID id)
                            throws CodeGenerationException
Throws:
CodeGenerationException

getFunctionRetTypeDecl

public java.lang.String getFunctionRetTypeDecl(Argument a,
                                               java.lang.String methodName)
                                        throws CodeGenerationException
Return the function declaration, tailored to BindC.

Parameters:
a - the argument
MethodName - the name of the current function name
Returns:
the argument declaration string Function return types in Fortran are the name of the function itself and as of 070208 this should only be called for 1) primitive SIDL types. 2) From within a logical branch that selects only BindC.
Throws:
CodeGenerationException

getArgumentDeclaration

public java.lang.String getArgumentDeclaration(Argument a)
                                        throws CodeGenerationException
Return the argument declaration, tailored to the specific flavor of FORTRAN.

Parameters:
a - the argument
Returns:
the argument declaration string
Throws:
CodeGenerationException

findCollisions

public java.util.Map findCollisions(java.util.Map methodsSeen,
                                    Symbol sym)
                             throws CodeGenerationException
Throws:
CodeGenerationException

addUseForReferences

public void addUseForReferences(Method m,
                                SymbolID id)
                         throws CodeGenerationException
Throws:
CodeGenerationException

generateCode

public void generateCode(Class cls)
                  throws CodeGenerationException
Generate the implementation FORTRAN file for a sidl class. The implementation file contains all the subroutines that need to be implemented for the class, and when replacing an implementation file, the previous implementation is retained.

Parameters:
cls - the sidl class whose implementation is to be written.
Throws:
CodeGenerationException - a catch all exception to indicate problems in the code generation phase.

generateCode

public static void generateCode(Class cls,
                                LanguageWriterForFortran writer,
                                CodeSplicer splicer,
                                Context context)
                         throws CodeGenerationException,
                                java.security.NoSuchAlgorithmException
Generate the implementation FORTRAN file for a sidl class. The implementation file contains all the subroutines that need to be implemented for the class, and when replacing an implementation file, the previous implementation is retained.

Throws:
CodeGenerationException - a catch all exception to indicate problems in the code generation phase.
java.security.NoSuchAlgorithmException - A problem with the name mangler.

isInt

public static boolean isInt(java.lang.String s)

isFortranFunction

public static boolean isFortranFunction(Type check,
                                        Context context)
Utility function that checks if we have a fortran function that returns primitve types.

Parameters:
Type - is m.getReturnType()