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