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