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