001 /* This file was generated with JastAdd2 (http://jastadd.org) version R20130213 */ 002 package AST; 003 004 import java.util.HashSet; 005 import java.io.File; 006 import java.util.*; 007 import beaver.*; 008 import java.util.ArrayList; 009 import java.util.zip.*; 010 import java.io.*; 011 import java.io.FileNotFoundException; 012 import java.util.Collection; 013 /** 014 * @production InstanceOfExpr : {@link Expr} ::= <span class="component">{@link Expr}</span> <span class="component">TypeAccess:{@link Access}</span>; 015 * @ast node 016 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/java.ast:185 017 */ 018 public class InstanceOfExpr extends Expr implements Cloneable { 019 /** 020 * @apilevel low-level 021 */ 022 public void flushCache() { 023 } 024 /** 025 * @apilevel internal 026 */ 027 public void flushCollectionCache() { 028 } 029 /** 030 * @apilevel internal 031 */ 032 @SuppressWarnings({"unchecked", "cast"}) 033 public InstanceOfExpr clone() throws CloneNotSupportedException { 034 InstanceOfExpr node = (InstanceOfExpr)super.clone(); 035 node.type_computed = false; 036 node.type_value = null; 037 node.in$Circle(false); 038 node.is$Final(false); 039 return node; 040 } 041 /** 042 * @apilevel internal 043 */ 044 @SuppressWarnings({"unchecked", "cast"}) 045 public InstanceOfExpr copy() { 046 047 try { 048 InstanceOfExpr node = (InstanceOfExpr) clone(); 049 node.parent = null; 050 if(children != null) 051 node.children = (ASTNode[]) children.clone(); 052 053 return node; 054 } catch (CloneNotSupportedException e) { 055 throw new Error("Error: clone not supported for " + getClass().getName()); 056 } 057 058 }/** 059 * Create a deep copy of the AST subtree at this node. 060 * The copy is dangling, i.e. has no parent. 061 * @return dangling copy of the subtree at this node 062 * @apilevel low-level 063 */ 064 @SuppressWarnings({"unchecked", "cast"}) 065 public InstanceOfExpr fullCopy() { 066 067 InstanceOfExpr tree = (InstanceOfExpr) copy(); 068 if (children != null) { 069 for (int i = 0; i < children.length; ++i) { 070 071 ASTNode child = (ASTNode) children[i]; 072 if(child != null) { 073 child = child.fullCopy(); 074 tree.setChild(child, i); 075 } 076 } 077 } 078 return tree; 079 080 } /** 081 * @ast method 082 * @aspect PrettyPrint 083 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/PrettyPrint.jadd:421 084 */ 085 public void toString(StringBuffer s) { 086 getExpr().toString(s); 087 s.append(" instanceof "); 088 getTypeAccess().toString(s); 089 } 090 /** 091 * @ast method 092 * @aspect TypeCheck 093 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeCheck.jrag:235 094 */ 095 public void typeCheck() { 096 TypeDecl relationalExpr = getExpr().type(); 097 TypeDecl referenceType = getTypeAccess().type(); 098 if(!relationalExpr.isUnknown()) { 099 if(!relationalExpr.isReferenceType() && !relationalExpr.isNull()) 100 error("The relational expression in instance of must be reference or null type"); 101 if(!referenceType.isReferenceType()) 102 error("The reference expression in instance of must be reference type"); 103 if(!relationalExpr.castingConversionTo(referenceType)) 104 error("The type " + relationalExpr.typeName() + " of the relational expression " + 105 getExpr() + " can not be cast into the type " + referenceType.typeName()); 106 if(getExpr().isTypeAccess()) 107 error("The relational expression " + getExpr() + " must not be a type name"); 108 } 109 } 110 /** 111 * @ast method 112 * @aspect CreateBCode 113 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CreateBCode.jrag:1169 114 */ 115 public void createBCode(CodeGeneration gen) { 116 getExpr().createBCode(gen); 117 gen.emitInstanceof(getTypeAccess().type()); 118 } 119 /** 120 * @ast method 121 * 122 */ 123 public InstanceOfExpr() { 124 super(); 125 126 127 } 128 /** 129 * Initializes the child array to the correct size. 130 * Initializes List and Opt nta children. 131 * @apilevel internal 132 * @ast method 133 * @ast method 134 * 135 */ 136 public void init$Children() { 137 children = new ASTNode[2]; 138 } 139 /** 140 * @ast method 141 * 142 */ 143 public InstanceOfExpr(Expr p0, Access p1) { 144 setChild(p0, 0); 145 setChild(p1, 1); 146 } 147 /** 148 * @apilevel low-level 149 * @ast method 150 * 151 */ 152 protected int numChildren() { 153 return 2; 154 } 155 /** 156 * @apilevel internal 157 * @ast method 158 * 159 */ 160 public boolean mayHaveRewrite() { 161 return false; 162 } 163 /** 164 * Replaces the Expr child. 165 * @param node The new node to replace the Expr child. 166 * @apilevel high-level 167 * @ast method 168 * 169 */ 170 public void setExpr(Expr node) { 171 setChild(node, 0); 172 } 173 /** 174 * Retrieves the Expr child. 175 * @return The current node used as the Expr child. 176 * @apilevel high-level 177 * @ast method 178 * 179 */ 180 public Expr getExpr() { 181 return (Expr)getChild(0); 182 } 183 /** 184 * Retrieves the Expr child. 185 * <p><em>This method does not invoke AST transformations.</em></p> 186 * @return The current node used as the Expr child. 187 * @apilevel low-level 188 * @ast method 189 * 190 */ 191 public Expr getExprNoTransform() { 192 return (Expr)getChildNoTransform(0); 193 } 194 /** 195 * Replaces the TypeAccess child. 196 * @param node The new node to replace the TypeAccess child. 197 * @apilevel high-level 198 * @ast method 199 * 200 */ 201 public void setTypeAccess(Access node) { 202 setChild(node, 1); 203 } 204 /** 205 * Retrieves the TypeAccess child. 206 * @return The current node used as the TypeAccess child. 207 * @apilevel high-level 208 * @ast method 209 * 210 */ 211 public Access getTypeAccess() { 212 return (Access)getChild(1); 213 } 214 /** 215 * Retrieves the TypeAccess child. 216 * <p><em>This method does not invoke AST transformations.</em></p> 217 * @return The current node used as the TypeAccess child. 218 * @apilevel low-level 219 * @ast method 220 * 221 */ 222 public Access getTypeAccessNoTransform() { 223 return (Access)getChildNoTransform(1); 224 } 225 /** 226 * @attribute syn 227 * @aspect ConstantExpression 228 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/ConstantExpression.jrag:336 229 */ 230 public boolean isConstant() { 231 ASTNode$State state = state(); 232 try { return false; } 233 finally { 234 } 235 } 236 /** 237 * @attribute syn 238 * @aspect DA 239 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:333 240 */ 241 public boolean isDAafterFalse(Variable v) { 242 ASTNode$State state = state(); 243 try { return isDAafter(v); } 244 finally { 245 } 246 } 247 /*eq Stmt.isDAafter(Variable v) { 248 //System.out.println("### isDAafter reached in " + getClass().getName()); 249 //throw new NullPointerException(); 250 throw new Error("Can not compute isDAafter for " + getClass().getName() + " at " + errorPrefix()); 251 }* @attribute syn 252 * @aspect DA 253 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:332 254 */ 255 public boolean isDAafterTrue(Variable v) { 256 ASTNode$State state = state(); 257 try { return isDAafter(v); } 258 finally { 259 } 260 } 261 /** 262 * @attribute syn 263 * @aspect DA 264 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:235 265 */ 266 public boolean isDAafter(Variable v) { 267 ASTNode$State state = state(); 268 try { return getExpr().isDAafter(v); } 269 finally { 270 } 271 } 272 /** 273 * @attribute syn 274 * @aspect DU 275 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:694 276 */ 277 public boolean isDUafter(Variable v) { 278 ASTNode$State state = state(); 279 try { return getExpr().isDUafter(v); } 280 finally { 281 } 282 } 283 /** 284 * @apilevel internal 285 */ 286 protected boolean type_computed = false; 287 /** 288 * @apilevel internal 289 */ 290 protected TypeDecl type_value; 291 /** 292 * @attribute syn 293 * @aspect TypeAnalysis 294 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:361 295 */ 296 @SuppressWarnings({"unchecked", "cast"}) 297 public TypeDecl type() { 298 if(type_computed) { 299 return type_value; 300 } 301 ASTNode$State state = state(); 302 int num = state.boundariesCrossed; 303 boolean isFinal = this.is$Final(); 304 type_value = type_compute(); 305 if(isFinal && num == state().boundariesCrossed){ type_computed = true; } 306 return type_value; 307 } 308 /** 309 * @apilevel internal 310 */ 311 private TypeDecl type_compute() { return typeBoolean(); } 312 /** 313 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/SyntacticClassification.jrag:89 314 * @apilevel internal 315 */ 316 public NameType Define_NameType_nameType(ASTNode caller, ASTNode child) { 317 if(caller == getTypeAccessNoTransform()) { 318 return NameType.TYPE_NAME; 319 } 320 else { return getParent().Define_NameType_nameType(this, caller); 321 } 322 } 323 /** 324 * @apilevel internal 325 */ 326 public ASTNode rewriteTo() { 327 return super.rewriteTo(); 328 } 329 }