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