|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcetus.hir.Declaration
cetus.hir.ClassDeclaration
public class ClassDeclaration
Represents a class, struct, or union. These are actually specifiers in C and C++, since variables can be declared immediately following the class declaration, but that's mostly syntactic sugar. We assume it can be split into a class declaration followed by a variable declaration. We have a single class representing all three (class, struct, union) because they are fundamentally the same except for default access levels and storage layout, which do not make a significant difference to source-to-source compilers. Anonymous structs should be given a unique name (most compilers do this internally anyway).
| Nested Class Summary | |
|---|---|
static class |
ClassDeclaration.Key
|
| Field Summary | |
|---|---|
static ClassDeclaration.Key |
CLASS
|
static ClassDeclaration.Key |
INTERFACE
|
static java.lang.reflect.Method |
print_as_cpp
|
static java.lang.reflect.Method |
print_as_java
|
static ClassDeclaration.Key |
STRUCT
|
static ClassDeclaration.Key |
UNION
|
| Fields inherited from class cetus.hir.Declaration |
|---|
children, object_print_method, parent |
| Constructor Summary | |
|---|---|
ClassDeclaration(ClassDeclaration.Key type,
IDExpression name)
Creates an empty class. |
|
ClassDeclaration(ClassDeclaration.Key type,
IDExpression name,
boolean no_body)
Creates a class. |
|
ClassDeclaration(java.util.List class_specs,
ClassDeclaration.Key type,
IDExpression name)
|
|
| Method Summary | |
|---|---|
void |
addBaseClass(IDExpression name)
|
void |
addBaseClass(Specifier access,
Identifier name)
|
void |
addBaseInterface(IDExpression name)
|
void |
addDeclaration(Declaration decl)
Add a declaration to the end of the set of declarations and place the declared symbols in the symbol table. |
void |
addDeclarationAfter(Declaration ref,
Declaration decl)
Add a declaration after the reference declaration. |
void |
addDeclarationBefore(Declaration ref,
Declaration decl)
Add a declaration before the reference declaration. |
static void |
defaultPrint(ClassDeclaration decl,
java.io.OutputStream stream)
Prints a class to a stream. |
Declaration |
findSymbol(IDExpression name)
Retrieves the declaration for a symbol, possibly searching through parent symbol tables. |
java.util.List |
getDeclaredSymbols()
Returns a list of IDExpressions that are the symbols introduced by this declaration. |
ClassDeclaration.Key |
getKey()
|
IDExpression |
getName()
|
java.util.List |
getParentTables()
Returns a list of symbol tables that are parents of this table in the distributed symbol table graph. |
java.util.HashMap |
getTable()
Provides direct access to the symbol table; it's generally not a good idea to modify this directly. |
static void |
printCpp(ClassDeclaration decl,
java.io.OutputStream stream)
Prints a C++ class to a stream. |
static void |
printJava(ClassDeclaration decl,
java.io.OutputStream stream)
Prints a Java class to a stream. |
void |
removeChild(Traversable child)
Removes the specified child. |
static void |
setClassPrintMethod(java.lang.reflect.Method m)
Overrides the class print method, so that all subsequently created objects will use the supplied method. |
java.lang.String |
toString()
|
| Methods inherited from class cetus.hir.Declaration |
|---|
clone, detach, getChildren, getParent, print, setChild, setParent, setPrintMethod, verify |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.reflect.Method print_as_cpp
public static final java.lang.reflect.Method print_as_java
public static final ClassDeclaration.Key CLASS
public static final ClassDeclaration.Key STRUCT
public static final ClassDeclaration.Key UNION
public static final ClassDeclaration.Key INTERFACE
| Constructor Detail |
|---|
public ClassDeclaration(java.util.List class_specs,
ClassDeclaration.Key type,
IDExpression name)
public ClassDeclaration(ClassDeclaration.Key type,
IDExpression name)
type - Must be one of CLASS, STRUCT, UNION, or INTERFACE.name - The name for the class.
public ClassDeclaration(ClassDeclaration.Key type,
IDExpression name,
boolean no_body)
type - Must be one of CLASS, STRUCT, UNION, or INTERFACE.name - The name for the class.no_body - True if this a forward declaration.| Method Detail |
|---|
public void addBaseClass(IDExpression name)
public void addBaseClass(Specifier access,
Identifier name)
public void addBaseInterface(IDExpression name)
public void addDeclaration(Declaration decl)
SymbolTable
addDeclaration in interface SymbolTabledecl - The declaration to add.
public void addDeclarationBefore(Declaration ref,
Declaration decl)
SymbolTable
addDeclarationBefore in interface SymbolTableref - The reference point.decl - The declaration to add.
public void addDeclarationAfter(Declaration ref,
Declaration decl)
SymbolTable
addDeclarationAfter in interface SymbolTableref - The reference point.decl - The declaration to add.
public static void defaultPrint(ClassDeclaration decl,
java.io.OutputStream stream)
decl - The class to print.stream - The stream on which to print the class.public Declaration findSymbol(IDExpression name)
SymbolTable
findSymbol in interface SymbolTablename - The name of the symbol.public java.util.List getDeclaredSymbols()
Declaration
getDeclaredSymbols in class Declarationpublic ClassDeclaration.Key getKey()
public IDExpression getName()
public java.util.List getParentTables()
SymbolTable
getParentTables in interface SymbolTablepublic java.util.HashMap getTable()
SymbolTable
getTable in interface SymbolTable
public static void printCpp(ClassDeclaration decl,
java.io.OutputStream stream)
decl - The class to print.stream - The stream on which to print the class.public java.lang.String toString()
toString in class Declaration
public static void printJava(ClassDeclaration decl,
java.io.OutputStream stream)
decl - The class to print.stream - The stream on which to print the class.public void removeChild(Traversable child)
Traversable
removeChild in interface TraversableremoveChild in class Declarationchild - a reference to a child object that must match with ==.public static void setClassPrintMethod(java.lang.reflect.Method m)
m - The new print method.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||