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     * Represents an ObjectDesignator of the form "Expr . ".
024     *
025     * Is created both by the parser (eg for "(x).y"),
026     * and by the name resolution code (eg for "x.y").
027     */
028    
029    public class ExprObjectDesignator extends ObjectDesignator
030    {
031      public /*@ non_null @*/ Expr expr;
032    
033      public int getStartLoc() { return expr.getStartLoc(); }
034      public Type type;
035      public Type type() { return type; }
036    
037    
038    // Generated boilerplate constructors:
039    
040      /**
041       * Construct a raw ExprObjectDesignator whose class invariant(s) have not
042       * yet been established.  It is the caller's job to
043       * initialize the returned node's fields so that any
044       * class invariants hold.
045       */
046      //@ requires I_will_establish_invariants_afterwards;
047      protected ExprObjectDesignator() {}    //@ nowarn Invariant,NonNullInit;
048    
049    
050    // Generated boilerplate methods:
051    
052      public final int childCount() {
053         return 1;
054      }
055    
056      public final Object childAt(int index) {
057              /*throws IndexOutOfBoundsException*/
058         if (index < 0)
059            throw new IndexOutOfBoundsException("AST child index " + index);
060         int indexPre = index;
061    
062         int sz;
063    
064         if (index == 0) return this.expr;
065         else index--;
066    
067         throw new IndexOutOfBoundsException("AST child index " + indexPre);
068      }   //@ nowarn Exception;
069    
070      public final String toString() {
071         return "[ExprObjectDesignator"
072            + " locDot = " + this.locDot
073            + " expr = " + this.expr
074            + "]";
075      }
076    
077      public final int getTag() {
078         return TagConstants.EXPROBJECTDESIGNATOR;
079      }
080    
081      public final void accept(Visitor v) { v.visitExprObjectDesignator(this); }
082    
083      public final Object accept(VisitorArgResult v, Object o) {return v.visitExprObjectDesignator(this, o); }
084    
085      public void check() {
086         super.check();
087         this.expr.check();
088      }
089    
090      //@ requires locDot != javafe.util.Location.NULL;
091      //@ ensures \result != null;
092      public static ExprObjectDesignator make(int locDot, /*@ non_null @*/ Expr expr) {
093         //@ set I_will_establish_invariants_afterwards = true;
094         ExprObjectDesignator result = new ExprObjectDesignator();
095         result.locDot = locDot;
096         result.expr = expr;
097         return result;
098      }
099    }