001    // -*- mode: java -*-
002    /* Copyright 2000, 2001, Compaq Computer Corporation */
003    
004    /* IF THIS IS A JAVA FILE, DO NOT EDIT IT!  
005    
006       Most Java files in this directory which are part of the Javafe AST
007       are automatically generated using the astgen comment (see
008       ESCTools/Javafe/astgen) from the input file 'hierarchy.h'.  If you
009       wish to modify AST classes or introduce new ones, modify
010       'hierarchy.j.'
011     */
012    
013    package javafe.ast;
014    
015    import javafe.util.Assert;
016    import javafe.util.Location;
017    import javafe.util.ErrorSet;
018    
019    // Convention: unless otherwise noted, integer fields named "loc" refer
020    // to the location of the first character of the syntactic unit
021    
022    
023    /* ---------------------------------------------------------------------- */
024    
025    /** Represents all variable declarations, including field declarations,
026     *  local variables and formal arguments.
027     *
028     *  We 'unroll' field and variable decls, 
029     *  so "<code>int x,y;</code>" becomes "<code>int x; int y;</code>".
030     *  This unrolling can be detected by looking for sequential
031     *  <code>VarDecl</code>s whose <code>Type</code> fields have the same
032     *  starting location.
033     */
034    
035    public abstract class GenericVarDecl extends ASTNode
036    {
037      public int modifiers;
038    
039      public ModifierPragmaVec pmodifiers;
040    
041      public /*@ non_null @*/ Identifier id;
042    
043      public /*@ non_null @*/ Type type;
044    
045      public int locId;
046    
047    
048      //xxx  public boolean isInternal() { return locId == javafe.util.Location.NULL; }
049    
050      //@ public represents startLoc <- type.getStartLoc();
051      public /*@ pure @*/ int getStartLoc() { return type.getStartLoc(); }
052      //@ also public normal_behavior
053      //@ ensures \result == type.getEndLoc();
054      public /*@ pure @*/ int getEndLoc() { return type.getEndLoc(); }
055      public int getModifiers() { return modifiers; }
056      public void setModifiers(int m) { modifiers = m; }
057    
058      protected GenericVarDecl(int modifiers, ModifierPragmaVec pmodifiers, /*@ non_null @*/ Identifier id, /*@ non_null @*/ Type type) {
059         super();
060         this.modifiers = modifiers;
061         this.pmodifiers = pmodifiers;
062         this.id = id;
063         this.type = type;
064         this.locId = Location.NULL;
065      }
066    
067    
068    // Generated boilerplate constructors:
069    
070      //@ ensures this.modifiers == modifiers;
071      //@ ensures this.pmodifiers == pmodifiers;
072      //@ ensures this.id == id;
073      //@ ensures this.type == type;
074      //@ ensures this.locId == locId;
075      protected GenericVarDecl(int modifiers, ModifierPragmaVec pmodifiers, /*@ non_null @*/ Identifier id, /*@ non_null @*/ Type type, int locId) {
076         super();
077         this.modifiers = modifiers;
078         this.pmodifiers = pmodifiers;
079         this.id = id;
080         this.type = type;
081         this.locId = locId;
082      }
083      public void check() {
084         super.check();
085         if (this.pmodifiers != null)
086            for(int i = 0; i < this.pmodifiers.size(); i++)
087               this.pmodifiers.elementAt(i).check();
088         if (this.id == null) throw new RuntimeException();
089         this.type.check();
090      }
091    
092    }