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