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