gov.llnl.babel.backend.sidl

Class ScopedName


public class ScopedName
extends java.lang.Object

When generating SIDL from the information stored in the Symbol table, it does not know what symbols where given as fully qualified names (fqn) and what symbols where given as short names using an import or the current scope to shorten the name. This class tries to provide a reasonable set of require statements to give a meaningful file.

Field Summary

static char
s_delim
The delimiter used to separate the symbol and version in require entry keys.

Method Summary

static String
getScopedName(String currentScope, String fullyQualifiedName)
Generate the scope sensitive name for a symbol.
static void
printRequires(Context context, Package pkg, LanguageWriter lw)
Build then print the require statements associated with the package.

Field Details

s_delim

public static char s_delim
The delimiter used to separate the symbol and version in require entry keys.

Method Details

getScopedName

public static String getScopedName(String currentScope,
                                   String fullyQualifiedName)
Generate the scope sensitive name for a symbol. This method takes into effect the requires list and the current scope.
Parameters:
currentScope - this is name of the scope in which you are writing. For example, if you're writing the package gov.cca, you would pass in "gov.cca".
fullyQualifiedName - you want the short name for this fully qualified name in the current scope and given a set of require statements printed at the beginning of the file.
Returns:
a short name if a short name is possible; otherwise, this returns the fully qualified name. fullyQualifiedName.endsWith(return value) should always be true.

printRequires

public static void printRequires(Context context,
                                 Package pkg,
                                 LanguageWriter lw)
Build then print the require statements associated with the package. The statements are output in alphabetical order, with the highest level parent package with the same version as appears in the symbols associated with the package.
Parameters:
pkg - the package whose requires list is to be built
lw - the language writer to which the requires are to be written