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 ModelConstructorDeclPragma extends TypeDeclElemPragma
031    {
032      public /*@ non_null @*/ ConstructorDecl decl;
033    
034      public int loc;
035    
036      public /*@ non_null @*/ SimpleName id;
037    
038    
039      public void setParent(TypeDecl p) {
040        super.setParent(p);
041        if (decl != null) 
042            decl.setParent(p);
043      }
044    
045      public int getStartLoc() { return loc; }
046      public int getEndLoc() { return decl.getEndLoc(); }
047      public void decorate(ModifierPragmaVec modifierPragmas) {
048        if (decl.pmodifiers == null) {
049            decl.pmodifiers = modifierPragmas;
050        } else if (modifierPragmas != null) {
051            // FIXME - should be prepen???
052            decl.pmodifiers.append(modifierPragmas); 
053        }
054      }
055    
056    
057    // Generated boilerplate constructors:
058    
059      /**
060       * Construct a raw ModelConstructorDeclPragma whose class invariant(s) have not
061       * yet been established.  It is the caller's job to
062       * initialize the returned node's fields so that any
063       * class invariants hold.
064       */
065      //@ requires I_will_establish_invariants_afterwards;
066      protected ModelConstructorDeclPragma() {}    //@ nowarn Invariant,NonNullInit;
067    
068    
069    // Generated boilerplate methods:
070    
071      public final int childCount() {
072         return 2;
073      }
074    
075      public final Object childAt(int index) {
076              /*throws IndexOutOfBoundsException*/
077         if (index < 0)
078            throw new IndexOutOfBoundsException("AST child index " + index);
079         int indexPre = index;
080    
081         int sz;
082    
083         if (index == 0) return this.decl;
084         else index--;
085    
086         if (index == 0) return this.id;
087         else index--;
088    
089         throw new IndexOutOfBoundsException("AST child index " + indexPre);
090      }   //@ nowarn Exception;
091    
092      public final String toString() {
093         return "[ModelConstructorDeclPragma"
094            + " decl = " + this.decl
095            + " loc = " + this.loc
096            + " id = " + this.id
097            + "]";
098      }
099    
100      public final int getTag() {
101         return TagConstants.MODELCONSTRUCTORDECLPRAGMA;
102      }
103    
104      public final void accept(javafe.ast.Visitor v) { 
105        if (v instanceof Visitor) ((Visitor)v).visitModelConstructorDeclPragma(this);
106      }
107    
108      public final Object accept(javafe.ast.VisitorArgResult v, Object o) { 
109        if (v instanceof VisitorArgResult) return ((VisitorArgResult)v).visitModelConstructorDeclPragma(this, o); else return null;
110      }
111    
112      public void check() {
113         this.decl.check();
114         this.id.check();
115      }
116    
117      //@ ensures \result != null;
118      public static ModelConstructorDeclPragma make(/*@ non_null @*/ ConstructorDecl decl, int loc, /*@ non_null @*/ SimpleName id) {
119         //@ set I_will_establish_invariants_afterwards = true;
120         ModelConstructorDeclPragma result = new ModelConstructorDeclPragma();
121         result.decl = decl;
122         result.loc = loc;
123         result.id = id;
124         return result;
125      }
126    }