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 escjava.ast;
014    
015    import java.util.Hashtable;
016    import java.util.Set;
017    import java.util.ArrayList;
018    
019    import javafe.ast.*;
020    import javafe.util.Assert;
021    import javafe.util.Location;
022    import escjava.ParsedRoutineSpecs;
023    
024    // Convention: unless otherwise noted, integer fields named "loc" refer
025    // to the location of the first character of the syntactic unit
026    
027    //# TagBase javafe.tc.TagConstants.LAST_TAG + 1
028    //# VisitorRoot javafe.ast.Visitor
029    
030    
031    /**
032     * @note If <code>loc</code> is <code>Location.NULL</code>, then this
033     * node is <em>not</em> due to a source-level "type" construct in an
034     * annotation expression but rather was created during translations.
035     */
036    
037    public class TypeExpr extends GCExpr
038    {
039      public /*@ non_null @*/ Type type;
040    
041    
042      //@ public represents startLoc <- sloc; //FIXME should not have to repeat this (because its in GCExpr)
043    
044    
045    // Generated boilerplate constructors:
046    
047      //@ ensures this.sloc == sloc;
048      //@ ensures this.eloc == eloc;
049      //@ ensures this.type == type;
050      protected TypeExpr(int sloc, int eloc, /*@ non_null @*/ Type type) {
051         super(sloc, eloc);
052         this.type = type;
053      }
054    
055    // Generated boilerplate methods:
056    
057      public final int childCount() {
058         return 1;
059      }
060    
061      public final Object childAt(int index) {
062              /*throws IndexOutOfBoundsException*/
063         if (index < 0)
064            throw new IndexOutOfBoundsException("AST child index " + index);
065         int indexPre = index;
066    
067         int sz;
068    
069         if (index == 0) return this.type;
070         else index--;
071    
072         throw new IndexOutOfBoundsException("AST child index " + indexPre);
073      }   //@ nowarn Exception;
074    
075      public final /*@non_null*/String toString() {
076         return "[TypeExpr"
077            + " sloc = " + this.sloc
078            + " eloc = " + this.eloc
079            + " type = " + this.type
080            + "]";
081      }
082    
083      public final int getTag() {
084         return TagConstants.TYPEEXPR;
085      }
086    
087      public final void accept(javafe.ast.Visitor v) { 
088        if (v instanceof Visitor) ((Visitor)v).visitTypeExpr(this);
089      }
090    
091      public final Object accept(javafe.ast.VisitorArgResult v, Object o) { 
092        if (v instanceof VisitorArgResult) return ((VisitorArgResult)v).visitTypeExpr(this, o); else return null;
093      }
094    
095      public void check() {
096         super.check();
097         this.type.check();
098      }
099    
100      //@ ensures \result != null;
101      public static TypeExpr make(int sloc, int eloc, /*@ non_null @*/ Type type) {
102         TypeExpr result = new TypeExpr(sloc, eloc, type);
103         return result;
104      }
105    }