Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javafe.ast
Class PrettyPrint

    java.lang.Object
      javafe.ast.PrettyPrint

Direct Known Subclasses:
  DelegatingPrettyPrint, StandardPrettyPrint

public abstract class PrettyPrint
extends java.lang.Object

Field Summary
`private static byte[]` | `_spaces`
`static boolean` | `displayInferred` Should we display code that is inferred?
`static int` | `INDENT` * Variables controling printing: * *
`static PrettyPrint` | `inst` The only instance front-end code should use to pretty print information.
`PrettyPrint` | `self` When an instance of PrettyPrint wishes to call itself recursively, it does not do so by using this, but rather by using this explicit self instance variable.

Constructor Summary
`protected` | `PrettyPrint()` Create a normal instance of PrettyPrint that does not have a runtime extension.
`protected` | `PrettyPrint(PrettyPrint self)` Create an instance of PrettyPrint that has a runtime extension.

Method Summary
`abstract void` | `print(java.io.OutputStream o, CompilationUnit cu)` Print a compilation onto to a stream.
`abstract void` | `print(java.io.OutputStream o, GenericVarDecl d)`
`abstract void` | `print(java.io.OutputStream o, int ind, ExprVec es)`
`abstract void` | `print(java.io.OutputStream o, int ind, FieldDecl d, boolean showBody)`
`abstract void` | `print(java.io.OutputStream o, int ind, FormalParaDeclVec fps)`
`abstract void` | `print(java.io.OutputStream o, int ind, LocalVarDecl d, boolean showBody)`
`abstract void` | `print(java.io.OutputStream o, int ind, ModifierPragma mp)` Print a member or static initializer of a type declaration.
`abstract void` | `print(java.io.OutputStream o, int ind, ObjectDesignator od)`
`abstract void` | `print(java.io.OutputStream o, int ind, Stmt s)` Print a statement.
`abstract void` | `print(java.io.OutputStream o, int ind, StmtPragma sp)`
`void` | `print(java.io.OutputStream o, int ind, TypeDecl d)` Print a type declaration onto to a stream.
`abstract void` | `print(java.io.OutputStream o, int ind, TypeDeclElem d, Identifier classId, boolean showBody)` Print a member or static initializer of a type declaration.
`abstract void` | `print(java.io.OutputStream o, int ind, TypeDeclElemPragma tp)`
`abstract void` | `print(java.io.OutputStream o, int ind, TypeModifierPragma tp)`
`abstract void` | `print(java.io.OutputStream o, int ind, VarInit e)`
`abstract void` | `print(java.io.OutputStream o, LexicalPragma lp)` Print a lexical pragma.
`abstract void` | `print(java.io.OutputStream o, Name n)`
`abstract void` | `print(java.io.OutputStream o, Type t)`
`abstract void` | `print(java.io.OutputStream o, TypeNameVec tns)`
`void` | `println(java.io.PrintStream out, Expr e)` Writes an Expr (a type of ASTNode) to the given PrintStream, followed by an end-of-line.
`void` | `println(java.io.PrintStream out, java.lang.Object e)` Writes an Object (a type of ASTNode) to the given PrintStream, followed by an end-of-line.
`void` | `println(java.io.PrintStream out, ObjectDesignator e)` Writes an ObjectDesignator (a type of ASTNode) to the given PrintStream, followed by an end-of-line.
`abstract void` | `printnoln(java.io.OutputStream o, int ind, TypeDecl d)` Print a type declaration onto to a stream, without a final newline.
`static void` | `spaces(java.io.OutputStream o, int number)`
`static java.lang.String` | `toCanonicalString(int tag, java.lang.Object val)` Returns a canonical text representation for literal values.
`java.lang.String` | `toString(ExprVec es)`
`java.lang.String` | `toString(FieldDecl d, boolean showBody)`
`java.lang.String` | `toString(FormalParaDeclVec fps)`
`java.lang.String` | `toString(GenericVarDecl d)`
`java.lang.String` | `toString(int tag)`
`java.lang.String` | `toString(LocalVarDecl d, boolean showBody)`
`java.lang.String` | `toString(Name n)`
`java.lang.String` | `toString(ObjectDesignator od)`
`java.lang.String` | `toString(Type t)`
`java.lang.String` | `toString(TypeNameVec tns)`
`java.lang.String` | `toString(VarInit e)`
`static void` | `write(java.io.OutputStream o, char c)`
`static void` | `write(java.io.OutputStream o, java.lang.String s)`
`static void` | `writeln(java.io.OutputStream o)`
`static void` | `writeln(java.io.OutputStream o, java.lang.String s)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### inst

    public static PrettyPrint inst

  The only instance front-end code should use to pretty print information.

  Will be some subclass of PrettyPrint; defaults to an instance of StandardPrettyPrint. Extensions should replace with an instance that understands how to pretty print the extensions.

### self

    public PrettyPrint self

  When an instance of PrettyPrint wishes to call itself recursively, it does not do so by using this, but rather by using this explicit self instance variable.

  This allows instances of PrettyPrint to be extended at runtime (rather than by compile-time static subclassing) using the DelegatingPrettyPrint class. See javafe.tc.TypePrint for an example of how this may be done.

### INDENT

    public static int INDENT

  * Variables controling printing: * *

### displayInferred

    public static boolean displayInferred

  Should we display code that is inferred?

  E.g., the inferred "this.", superclass constructor calls, etc.

### _spaces

    private static byte[] _spaces

Constructor Detail

### PrettyPrint

    protected PrettyPrint()

  Create a normal instance of PrettyPrint that does not have a runtime extension.

### PrettyPrint

    protected PrettyPrint(PrettyPrint self)

  Create an instance of PrettyPrint that has a runtime extension.

  Self should be an instance of DelegatingPrettyPrint that eventually calls us after some amount of filtering.

Method Detail

### print

    public abstract void print(java.io.OutputStream o,
                               CompilationUnit cu)

  Print a compilation onto to a stream. Works best when `o` is positioned at the start of a new line.

### print

    public void print(java.io.OutputStream o,
                      int ind,
                      TypeDecl d)

  Print a type declaration onto to a stream.

  Ends with a newline.

### printnoln

    public abstract void printnoln(java.io.OutputStream o,
                                   int ind,
                                   TypeDecl d)

  Print a type declaration onto to a stream, without a final newline.

### print

    public abstract void print(java.io.OutputStream o,
                               int ind,
                               Stmt s)

  Print a statement. Assumes that `s` should be printed starting at the current position of `o`. It does not print a new-line at the end of the statement. However, if the statement needs to span multiple lines (for example, because it has embedded statements), then these lines are indented by `ind` spaces.

### print

    public abstract void print(java.io.OutputStream o,
                               int ind,
                               TypeDeclElem d,
                               Identifier classId,
                               boolean showBody)

  Print a member or static initializer of a type declaration. Assumes that `s` should be printed starting at the current position of `o`. If the declaration needs to span multiple lines (for example, to print the statements in the body of a method), then these lines are indented by `ind` spaces. It should leave `o` at the start of a new-line.

### print

    public abstract void print(java.io.OutputStream o,
                               TypeNameVec tns)

### print

    public abstract void print(java.io.OutputStream o,
                               int ind,
                               FormalParaDeclVec fps)

### print

    public abstract void print(java.io.OutputStream o,
                               int ind,
                               ExprVec es)

### print

    public abstract void print(java.io.OutputStream o,
                               GenericVarDecl d)

### print

    public abstract void print(java.io.OutputStream o,
                               int ind,
                               LocalVarDecl d,
                               boolean showBody)

### print

    public abstract void print(java.io.OutputStream o,
                               int ind,
                               FieldDecl d,
                               boolean showBody)

### print

    public abstract void print(java.io.OutputStream o,
                               Type t)

### print

    public abstract void print(java.io.OutputStream o,
                               Name n)

### print

    public abstract void print(java.io.OutputStream o,
                               int ind,
                               ObjectDesignator od)

### print

    public abstract void print(java.io.OutputStream o,
                               int ind,
                               VarInit e)

### print

    public abstract void print(java.io.OutputStream o,
                               LexicalPragma lp)

  Print a lexical pragma. Assumes `o` is at the start of the line; should leave `o` at the start of a new line.

### print

    public abstract void print(java.io.OutputStream o,
                               int ind,
                               TypeDeclElemPragma tp)

### print

    public abstract void print(java.io.OutputStream o,
                               int ind,
                               ModifierPragma mp)

  Print a member or static initializer of a type declaration. Assumes that `s` should be printed starting at the current position of `o`. If the declaration needs to span multiple lines (for example, to print the statements in the body of a method), then these lines are indented by `ind` spaces. It should leave `o` at the start of a new-line.

### print

    public abstract void print(java.io.OutputStream o,
                               int ind,
                               StmtPragma sp)

### print

    public abstract void print(java.io.OutputStream o,
                               int ind,
                               TypeModifierPragma tp)

### println

    public void println(java.io.PrintStream out,
                        java.lang.Object e)

  Writes an Object (a type of ASTNode) to the given PrintStream, followed by an end-of-line.

  Parameters:
    `out` - The PrintStream to write to
    `e` - The expression to write

### println

    public void println(java.io.PrintStream out,
                        Expr e)

  Writes an Expr (a type of ASTNode) to the given PrintStream, followed by an end-of-line.

  Parameters:
    `out` - The PrintStream to write to
    `e` - The expression to write

### println

    public void println(java.io.PrintStream out,
                        ObjectDesignator e)

  Writes an ObjectDesignator (a type of ASTNode) to the given PrintStream, followed by an end-of-line.

  Parameters:
    `out` - The PrintStream to write to
    `e` - The expression to write

### toCanonicalString

    public static java.lang.String toCanonicalString(int tag,
                                                     java.lang.Object val)

  Returns a canonical text representation for literal values. Requires `tag` is one of constants on the left of this table:
  `

  TagConstants.BOOLEANLIT | Boolean
  TagConstants.CHARLIT | Integer
  TagConstants.DOUBLELIT | Double
  TagConstants.FLOATLIT | Float
  TagConstants.INTLIT | Integer
  TagConstants.LONGLIT | Long
  TagConstants.STRINGLIT | String

  `
  and that `val` is an instance of the corresponding type on the right.

### toString

    public java.lang.String toString(int tag)

### toString

    public final java.lang.String toString(TypeNameVec tns)

### toString

    public final java.lang.String toString(FormalParaDeclVec fps)

### toString

    public final java.lang.String toString(ExprVec es)

### toString

    public final java.lang.String toString(GenericVarDecl d)

### toString

    public final java.lang.String toString(LocalVarDecl d,
                                           boolean showBody)

### toString

    public final java.lang.String toString(FieldDecl d,
                                           boolean showBody)

### toString

    public final java.lang.String toString(Type t)

### toString

    public final java.lang.String toString(Name n)

### toString

    public final java.lang.String toString(VarInit e)

### toString

    public final java.lang.String toString(ObjectDesignator od)

### writeln

    public static void writeln(java.io.OutputStream o)

### writeln

    public static void writeln(java.io.OutputStream o,
                               java.lang.String s)

### write

    public static void write(java.io.OutputStream o,
                             char c)

### write

    public static void write(java.io.OutputStream o,
                             java.lang.String s)

### spaces

    public static void spaces(java.io.OutputStream o,
                              int number)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

The ESC/Java2 Project Homepage