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