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