cetus.hir
Class PreAnnotation

java.lang.Object
  extended by cetus.hir.Declaration
      extended by cetus.hir.PreAnnotation
All Implemented Interfaces:
Annotatable, Printable, Traversable, java.lang.Cloneable

public class PreAnnotation
extends Declaration

Represents a text annotation (comment or pragma) or a list of keyed values. Internally, an annotation is a single string or a map of keys to values. There is no restriction on the type or content of the keys and values. Compiler passes are free to use annotations as they see fit, although annotations used by multiple passes should be well-documented. By default, annotations are printed as a multi-line comment. They can also be printed as pragmas. If the text value of the annotation has been set, the text is printed, otherwise the list of keyed values is printed.


Field Summary
protected  java.util.HashMap map
           
static java.lang.reflect.Method print_as_comment_method
          Useful for passing to setPrintMethod or setClassPrintMethod.
static java.lang.reflect.Method print_as_pragma_method
          Useful for passing to setPrintMethod or setClassPrintMethod.
static java.lang.reflect.Method print_raw_method
          Useful for passing to setPrintMethod or setClassPrintMethod.
protected  java.lang.String text
           
 
Fields inherited from class cetus.hir.Declaration
annotations, children, object_print_method, parent, print_as_statement_method
 
Constructor Summary
PreAnnotation()
          Creates an empty annotation.
PreAnnotation(java.lang.String text)
          Creates a text annotation.
 
Method Summary
 void add(java.lang.Object key, java.lang.Object value)
           
static void defaultPrint(PreAnnotation note, java.io.OutputStream stream)
          Prints an annotation to a stream.
 boolean equals(java.lang.Object o)
           
 java.util.List getDeclaredSymbols()
          Returns a list of IDExpressions that are the symbols introduced by this declaration.
 java.util.Map getMap()
          Provides access to the annotation map.
 java.lang.String getText()
           
 int hashCode()
           
static void printAsComment(PreAnnotation note, java.io.OutputStream stream)
          Prints an annotation as a multi-line comment.
static void printAsPragma(PreAnnotation note, java.io.OutputStream stream)
          Prints an annotation as a single-line pragma.
static void printRaw(PreAnnotation note, java.io.OutputStream stream)
          Prints an annotation's contents without enclosing them in comments.
 void setChild(int index, Traversable t)
          Unsupported - this object has no children.
static void setClassPrintMethod(java.lang.reflect.Method m)
          Overrides the class print method, so that all subsequently created objects will use the supplied method.
 void setText(java.lang.String text)
          Sets the text of the annotation.
 java.lang.String toString()
          Returns a string for this annotation following the object print method.
 
Methods inherited from class cetus.hir.Declaration
annotate, annotateAfter, annotateBefore, annotationToString, clone, containsAnnotation, detach, getAnnotation, getAnnotations, getAnnotations, getAnnotations, getChildren, getParent, print, printAsStatement, removeAnnotations, removeAnnotations, removeChild, setParent, setPrintMethod, toAnnotatedString, verify
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

print_as_comment_method

public static final java.lang.reflect.Method print_as_comment_method
Useful for passing to setPrintMethod or setClassPrintMethod.


print_as_pragma_method

public static final java.lang.reflect.Method print_as_pragma_method
Useful for passing to setPrintMethod or setClassPrintMethod.


print_raw_method

public static final java.lang.reflect.Method print_raw_method
Useful for passing to setPrintMethod or setClassPrintMethod.


map

protected java.util.HashMap map

text

protected java.lang.String text
Constructor Detail

PreAnnotation

public PreAnnotation()
Creates an empty annotation.


PreAnnotation

public PreAnnotation(java.lang.String text)
Creates a text annotation.

Parameters:
text - The text to be used as a comment or pragma.
Method Detail

add

public void add(java.lang.Object key,
                java.lang.Object value)

defaultPrint

public static void defaultPrint(PreAnnotation note,
                                java.io.OutputStream stream)
Prints an annotation to a stream.

Parameters:
note - The annotation to print.
stream - The stream on which to print the annotation.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

getDeclaredSymbols

public java.util.List getDeclaredSymbols()
Description copied from class: Declaration
Returns a list of IDExpressions that are the symbols introduced by this declaration.

Specified by:
getDeclaredSymbols in class Declaration
Returns:
a list of IDExpressions. The list will not be null but may be empty.

getMap

public java.util.Map getMap()
Provides access to the annotation map.


getText

public java.lang.String getText()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

printAsComment

public static void printAsComment(PreAnnotation note,
                                  java.io.OutputStream stream)
Prints an annotation as a multi-line comment.

Parameters:
note - The annotation to print.
stream - The stream on which to print the annotation.

printAsPragma

public static void printAsPragma(PreAnnotation note,
                                 java.io.OutputStream stream)
Prints an annotation as a single-line pragma.

Parameters:
note - The annotation to print.
stream - The stream on which to print the annotation.

printRaw

public static void printRaw(PreAnnotation note,
                            java.io.OutputStream stream)
Prints an annotation's contents without enclosing them in comments.

Parameters:
note - The annotation to print.
stream - The stream on which to print the annotation.

toString

public java.lang.String toString()
Returns a string for this annotation following the object print method.

Specified by:
toString in class Declaration
Returns:
a string

setChild

public void setChild(int index,
                     Traversable t)
Unsupported - this object has no children.

Specified by:
setChild in interface Traversable
Overrides:
setChild in class Declaration

setClassPrintMethod

public static void setClassPrintMethod(java.lang.reflect.Method m)
Overrides the class print method, so that all subsequently created objects will use the supplied method.

Parameters:
m - The new print method.

setText

public void setText(java.lang.String text)
Sets the text of the annotation.

Parameters:
text - The text to be used as a comment or pragma.