001    /* Copyright 2000, 2001, Compaq Computer Corporation */
002    
003    /* IF THIS IS A JAVA FILE, DO NOT EDIT IT!  
004    
005       Most Java files in this directory which are part of the Javafe AST
006       are automatically generated using the astgen comment (see
007       ESCTools/Javafe/astgen) from the input file 'hierarchy.h'.  If you
008       wish to modify AST classes or introduce new ones, modify
009       'hierarchy.j.'
010     */
011    
012    package escjava.ast;
013    
014    import java.util.Hashtable;
015    import java.util.Set;
016    import java.util.ArrayList;
017    
018    import javafe.ast.*;
019    import javafe.util.Assert;
020    import javafe.util.Location;
021    import escjava.ParsedRoutineSpecs;
022    
023    // Convention: unless otherwise noted, integer fields named "loc" refer
024    // to the location of the first character of the syntactic unit
025    
026    //# TagBase javafe.tc.TagConstants.LAST_TAG + 1
027    //# VisitorRoot javafe.ast.Visitor
028    
029    
030    public class ModelTypePragma extends TypeDeclElemPragma
031    {
032      public /*@ non_null @*/ TypeDecl decl;
033    
034      public int loc;
035    
036    
037      public void setParent(TypeDecl p) {
038        super.setParent(p);
039        if (decl != null) 
040            decl.setParent(p);
041      }
042    
043      public int getStartLoc() { return loc; }
044      public int getEndLoc() { return decl.getEndLoc(); }
045      public void decorate(ModifierPragmaVec modifierPragmas) {
046        if (decl.pmodifiers == null) {
047            decl.pmodifiers = modifierPragmas;
048            // FIXME - should be prepen???
049        } else if (modifierPragmas != null) {
050            decl.pmodifiers.append(modifierPragmas); 
051        }
052      }
053    
054    
055    // Generated boilerplate constructors:
056    
057      /**
058       * Construct a raw ModelTypePragma whose class invariant(s) have not
059       * yet been established.  It is the caller's job to
060       * initialize the returned node's fields so that any
061       * class invariants hold.
062       */
063      //@ requires I_will_establish_invariants_afterwards;
064      protected ModelTypePragma() {}    //@ nowarn Invariant,NonNullInit;
065    
066    
067    // Generated boilerplate methods:
068    
069      public final int childCount() {
070         return 1;
071      }
072    
073      public final Object childAt(int index) {
074              /*throws IndexOutOfBoundsException*/
075         if (index < 0)
076            throw new IndexOutOfBoundsException("AST child index " + index);
077         int indexPre = index;
078    
079         int sz;
080    
081         if (index == 0) return this.decl;
082         else index--;
083    
084         throw new IndexOutOfBoundsException("AST child index " + indexPre);
085      }   //@ nowarn Exception;
086    
087      public final String toString() {
088         return "[ModelTypePragma"
089            + " decl = " + this.decl
090            + " loc = " + this.loc
091            + "]";
092      }
093    
094      public final int getTag() {
095         return TagConstants.MODELTYPEPRAGMA;
096      }
097    
098      public final void accept(javafe.ast.Visitor v) { 
099        if (v instanceof Visitor) ((Visitor)v).visitModelTypePragma(this);
100      }
101    
102      public final Object accept(javafe.ast.VisitorArgResult v, Object o) { 
103        if (v instanceof VisitorArgResult) return ((VisitorArgResult)v).visitModelTypePragma(this, o); else return null;
104      }
105    
106      public void check() {
107         this.decl.check();
108      }
109    
110      //@ ensures \result != null;
111      public static ModelTypePragma make(/*@ non_null @*/ TypeDecl decl, int loc) {
112         //@ set I_will_establish_invariants_afterwards = true;
113         ModelTypePragma result = new ModelTypePragma();
114         result.decl = decl;
115         result.loc = loc;
116         return result;
117      }
118    }