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 NumericalQuantifiedExpr extends GCExpr 031 { 032 // NumOf 033 public int quantifier; 034 035 public /*@ non_null @*/ GenericVarDeclVec vars; 036 037 public /*@ non_null @*/ Expr rangeExpr; 038 039 public /*@ non_null @*/ Expr expr; 040 041 public ExprVec nopats; 042 043 044 public final int getTag() { return quantifier; } 045 046 private void postCheck() { 047 boolean goodtag = 048 (quantifier == TagConstants.NUM_OF); 049 Assert.notFalse(goodtag); 050 } 051 052 053 // Generated boilerplate constructors: 054 055 /** 056 * Construct a raw NumericalQuantifiedExpr whose class invariant(s) have not 057 * yet been established. It is the caller's job to 058 * initialize the returned node's fields so that any 059 * class invariants hold. 060 */ 061 //@ requires I_will_establish_invariants_afterwards; 062 protected NumericalQuantifiedExpr() {} //@ nowarn Invariant,NonNullInit; 063 064 065 // Generated boilerplate methods: 066 067 public final int childCount() { 068 int sz = 0; 069 if (this.vars != null) sz += this.vars.size(); 070 if (this.nopats != null) sz += this.nopats.size(); 071 return sz + 2; 072 } 073 074 public final Object childAt(int index) { 075 /*throws IndexOutOfBoundsException*/ 076 if (index < 0) 077 throw new IndexOutOfBoundsException("AST child index " + index); 078 int indexPre = index; 079 080 int sz; 081 082 sz = (this.vars == null ? 0 : this.vars.size()); 083 if (0 <= index && index < sz) 084 return this.vars.elementAt(index); 085 else index -= sz; 086 087 if (index == 0) return this.rangeExpr; 088 else index--; 089 090 if (index == 0) return this.expr; 091 else index--; 092 093 sz = (this.nopats == null ? 0 : this.nopats.size()); 094 if (0 <= index && index < sz) 095 return this.nopats.elementAt(index); 096 else index -= sz; 097 098 throw new IndexOutOfBoundsException("AST child index " + indexPre); 099 } //@ nowarn Exception; 100 101 public final String toString() { 102 return "[NumericalQuantifiedExpr" 103 + " sloc = " + this.sloc 104 + " eloc = " + this.eloc 105 + " quantifier = " + this.quantifier 106 + " vars = " + this.vars 107 + " rangeExpr = " + this.rangeExpr 108 + " expr = " + this.expr 109 + " nopats = " + this.nopats 110 + "]"; 111 } 112 113 public final void accept(javafe.ast.Visitor v) { 114 if (v instanceof Visitor) ((Visitor)v).visitNumericalQuantifiedExpr(this); 115 } 116 117 public final Object accept(javafe.ast.VisitorArgResult v, Object o) { 118 if (v instanceof VisitorArgResult) return ((VisitorArgResult)v).visitNumericalQuantifiedExpr(this, o); else return null; 119 } 120 121 public void check() { 122 super.check(); 123 for(int i = 0; i < this.vars.size(); i++) 124 this.vars.elementAt(i).check(); 125 this.rangeExpr.check(); 126 this.expr.check(); 127 if (this.nopats != null) 128 for(int i = 0; i < this.nopats.size(); i++) 129 this.nopats.elementAt(i).check(); 130 postCheck(); 131 } 132 133 //@ ensures \result != null; 134 public static NumericalQuantifiedExpr make(int sloc, int eloc, int quantifier, /*@ non_null @*/ GenericVarDeclVec vars, /*@ non_null @*/ Expr rangeExpr, /*@ non_null @*/ Expr expr, ExprVec nopats) { 135 //@ set I_will_establish_invariants_afterwards = true; 136 NumericalQuantifiedExpr result = new NumericalQuantifiedExpr(); 137 result.sloc = sloc; 138 result.eloc = eloc; 139 result.quantifier = quantifier; 140 result.vars = vars; 141 result.rangeExpr = rangeExpr; 142 result.expr = expr; 143 result.nopats = nopats; 144 return result; 145 } 146 }