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 javafe.ast;
013    
014    import javafe.util.Assert;
015    import javafe.util.Location;
016    import javafe.util.ErrorSet;
017    
018    // Convention: unless otherwise noted, integer fields named "loc" refer
019    // to the location of the first character of the syntactic unit
020    
021    
022    /* ---------------------------------------------------------------------- */
023    
024    /** Represents both MethodDeclarations and ConstructorDeclarations.
025     */
026    
027    public abstract class RoutineDecl extends ASTNode implements TypeDeclElem
028    {
029      //@ invariant hasParent ==> parent != null;
030      public TypeDecl parent;
031    
032      public boolean binaryArgNames = false; // true if the ids of formal
033            // arguments are binary manufactured names instead of source code names
034    
035      public boolean implicit = false;
036      public TypeNameVec originalRaises = null;
037    
038      public int modifiers;
039    
040      public ModifierPragmaVec pmodifiers;
041    
042      public TypeModifierPragmaVec tmodifiers;
043    
044      public /*@ non_null @*/ FormalParaDeclVec args;
045    
046      public /*@ non_null @*/ TypeNameVec raises;
047    
048      public BlockStmt body;
049    
050      public int locOpenBrace;
051    
052      //@ invariant body != null ==> locOpenBrace != Location.NULL;
053      //@ invariant loc != javafe.util.Location.NULL;
054      public int loc;
055    
056      //@ invariant locId != javafe.util.Location.NULL;
057      public int locId;
058    
059    
060      // The "locThrowsKeyword" field should be used only if "raises" denotes
061      // a nonempty list, in which case "locThrowsKeyword" is not "Location.NULL"
062      public int locThrowsKeyword;
063    
064    
065      private void postCheck() {
066        // Check invariants on modifiers...
067    
068        for(int i = 0; i < args.size(); i++)
069          // Check invariants on modifiers...
070          /*skip*/;
071      }
072    
073      public TypeDecl getParent() { return parent; }
074      public void setParent(TypeDecl p) { parent = p; }
075    
076      public int getModifiers() { return modifiers; }
077      public void setModifiers(int m) { modifiers = m; }
078      public ModifierPragmaVec getPModifiers() { return pmodifiers; }
079      public int getStartLoc() { return loc; }
080      abstract public Identifier id();
081    
082        public int getEndLoc() { 
083            if (body == null)
084                return super.getEndLoc();
085    
086            return body.getEndLoc();
087        }
088      private Type[] argtypes = null;
089      public Type[] argTypes() {
090            if (argtypes != null) return argtypes;
091            argtypes = new Type[args.size()];
092            for (int i=0; i<args.size(); ++i) {
093                    argtypes[i] = args.elementAt(i).type;
094            }
095            return argtypes;
096      }
097    
098    
099    // Generated boilerplate constructors:
100    
101      /**
102       * Construct a raw RoutineDecl whose class invariant(s) have not
103       * yet been established.  It is the caller's job to
104       * initialize the returned node's fields so that any
105       * class invariants hold.
106       */
107      //@ requires I_will_establish_invariants_afterwards;
108      protected RoutineDecl() {}    //@ nowarn Invariant,NonNullInit;
109    
110      public void check() {
111         super.check();
112         if (this.pmodifiers != null)
113            for(int i = 0; i < this.pmodifiers.size(); i++)
114               this.pmodifiers.elementAt(i).check();
115         if (this.tmodifiers != null)
116            for(int i = 0; i < this.tmodifiers.size(); i++)
117               this.tmodifiers.elementAt(i).check();
118         for(int i = 0; i < this.args.size(); i++)
119            this.args.elementAt(i).check();
120         for(int i = 0; i < this.raises.size(); i++)
121            this.raises.elementAt(i).check();
122         if (this.body != null)
123            this.body.check();
124         postCheck();
125      }
126    
127    }