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    public class InstanceOfExpr extends Expr
024    {
025      public /*@ non_null @*/ Expr expr;
026    
027      //@ invariant type.syntax;
028      public /*@ non_null @*/ Type type;
029    
030      //@ invariant loc != javafe.util.Location.NULL;
031      public int loc;
032    
033    
034      //@ public represents startLoc <- expr.getStartLoc();
035      public /*@ pure @*/ int getStartLoc() { return expr.getStartLoc(); }
036      //@ also public normal_behavior
037      //@ ensures \result == type.getEndLoc();
038      public /*@ pure @*/ int getEndLoc() { return type.getEndLoc(); }
039    
040    
041    // Generated boilerplate constructors:
042    
043      //@ ensures this.expr == expr;
044      //@ ensures this.type == type;
045      //@ ensures this.loc == loc;
046      protected InstanceOfExpr(/*@ non_null @*/ Expr expr, /*@ non_null @*/ Type type, int loc) {
047         super();
048         this.expr = expr;
049         this.type = type;
050         this.loc = loc;
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.expr;
068         else index--;
069    
070         if (index == 0) return this.type;
071         else index--;
072    
073         throw new IndexOutOfBoundsException("AST child index " + indexPre);
074      }   //@ nowarn Exception;
075    
076      public final /*@non_null*/String toString() {
077         return "[InstanceOfExpr"
078            + " expr = " + this.expr
079            + " type = " + this.type
080            + " loc = " + this.loc
081            + "]";
082      }
083    
084      public final int getTag() {
085         return TagConstants.INSTANCEOFEXPR;
086      }
087    
088      public final void accept(Visitor v) { v.visitInstanceOfExpr(this); }
089    
090      public final Object accept(VisitorArgResult v, Object o) {return v.visitInstanceOfExpr(this, o); }
091    
092      public void check() {
093         super.check();
094         this.expr.check();
095         this.type.check();
096      }
097    
098      //@ requires type.syntax;
099      //@ requires loc != javafe.util.Location.NULL;
100      //@ ensures \result != null;
101      public static InstanceOfExpr make(/*@ non_null @*/ Expr expr, /*@ non_null @*/ Type type, int loc) {
102         InstanceOfExpr result = new InstanceOfExpr(expr, type, loc);
103         return result;
104      }
105    }