001    /* $Id: DelegatingPrettyPrint.java,v 1.6 2006/08/05 16:58:04 chalin Exp $
002     * Copyright 2000, 2001, Compaq Computer Corporation 
003     * Copyright 2006, DSRG, Concordia University
004     */
005    
006    package javafe.ast;
007    
008    import java.io.OutputStream;
009    import java.io.ByteArrayOutputStream;
010    import java.io.IOException;
011    import javafe.util.Assert;
012    import javafe.util.Location;
013    
014    public class DelegatingPrettyPrint extends PrettyPrint {
015    
016      /*@ spec_public */protected /*@ non_null */ PrettyPrint del;
017    
018      /** The contract for the default constructor does not say what del
019       * is initialied to, hence strongly hinting to clients that they
020       * need to initialize it explicitly. 
021       */
022      //@ ensures this.self == this;
023      //@ ensures_redundantly this.del != null;
024      protected DelegatingPrettyPrint() {
025          // del needs to be non-null and PrettyPrint.inst happens to be a
026          // meaningful value so use it as a filler until the client
027          // explicitly initialized del.
028          del = PrettyPrint.inst;
029      }
030      
031      //@ requires del != this;
032      //@ ensures this.self == self;
033      //@ ensures this.del == del;
034      protected DelegatingPrettyPrint(/*@ non_null */ PrettyPrint self, 
035                                      /*@ non_null */ PrettyPrint del) { 
036        super(self); 
037        this.del = del; 
038      }
039    
040      //@ requires del != this;
041      //@ ensures this.del == del;
042      public void setDel(PrettyPrint del) {
043          this.del = del;
044      }
045      
046      public void print(/*@ non_null @*/ OutputStream o, CompilationUnit cu) {
047        del.print(o, cu);
048      }
049      
050      public void printnoln(/*@ non_null @*/ OutputStream o, int ind, TypeDecl d) {
051        del.printnoln(o, ind, d);
052      }
053      
054      public void print(/*@ non_null @*/ OutputStream o, int ind, Stmt s) {
055        del.print(o, ind, s);
056      }
057      
058      public void print(/*@ non_null @*/ OutputStream o, 
059                        int ind, 
060                        /*@ nullable */ TypeDeclElem d, 
061                        /*@ non_null */ Identifier classId, 
062                        boolean showBody) {
063        del.print(o, ind, d, classId, showBody);
064      }
065      
066      public void print(/*@ non_null @*/ OutputStream o, TypeNameVec tns) {
067        del.print(o, tns);
068      }
069      
070      public void print(/*@ non_null @*/ OutputStream o, int ind, FormalParaDeclVec fps) {
071        del.print(o, ind, fps);
072      }
073      
074      public void print(/*@ non_null @*/ OutputStream o, int ind, ExprVec es) {
075        del.print(o, ind, es);
076      }
077      
078      public void print(/*@ non_null @*/ OutputStream o, GenericVarDecl d) {
079        del.print(o, d);
080      }
081      
082      public void print(/*@ non_null @*/ OutputStream o, int ind, LocalVarDecl d,
083                        boolean showBody) {
084        del.print(o, ind, d, showBody);
085      }
086      
087      public void print(/*@ non_null @*/ OutputStream o, int ind, FieldDecl d, boolean showBody) {
088        del.print(o, ind, d, showBody);
089      }
090      
091      public void print(/*@ non_null @*/ OutputStream o, /*@ non_null */ Type t) {
092        del.print(o, t);
093      }
094      
095      public void print(/*@ non_null @*/ OutputStream o, Name n) {
096        del.print(o, n);
097      }
098      
099      public void print(/*@ non_null @*/ OutputStream o, int ind, VarInit e) {
100        del.print(o, ind, e);
101      }
102      
103      public void print(/*@ non_null @*/ OutputStream o, int ind, ObjectDesignator od) {
104        del.print(o, ind, od);
105      }
106      
107      public void print(/*@ non_null @*/ OutputStream o, /*@ non_null */ LexicalPragma lp) {
108        del.print(o, lp);
109      }
110      
111      public void print(/*@ non_null @*/ OutputStream o, int ind, /*@ non_null */ TypeDeclElemPragma tp) {
112        del.print(o, ind, tp);
113      }
114      
115      public void print(/*@ non_null @*/ OutputStream o, int ind, /*@ non_null */ ModifierPragma mp) {
116        del.print(o, ind, mp);
117      }
118      
119      public void print(/*@ non_null @*/ OutputStream o, int ind, /*@ non_null */ StmtPragma sp) {
120        del.print(o, ind, sp);
121      }
122      
123      public void print(/*@ non_null @*/ OutputStream o, int ind, /*@ non_null */ TypeModifierPragma tp) {
124        del.print(o, ind, tp);
125      }
126      
127      public /*@ non_null @*/ String toString(int tag) {
128        return del.toString(tag);
129      }
130    }
131    
132    
133    
134