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 CastExpr : {@link Expr} ::= <span class="component">TypeAccess:{@link Access}</span> <span class="component">{@link Expr}</span>; 015 * @ast node 016 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/java.ast:144 017 */ 018 public class CastExpr 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 CastExpr clone() throws CloneNotSupportedException { 034 CastExpr node = (CastExpr)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 CastExpr copy() { 046 047 try { 048 CastExpr node = (CastExpr) 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 CastExpr fullCopy() { 066 067 CastExpr tree = (CastExpr) 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:385 084 */ 085 public void toString(StringBuffer s) { 086 s.append("("); 087 getTypeAccess().toString(s); 088 s.append(")"); 089 getExpr().toString(s); 090 } 091 /** 092 * @ast method 093 * @aspect TypeCheck 094 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeCheck.jrag:252 095 */ 096 public void typeCheck() { 097 TypeDecl expr = getExpr().type(); 098 TypeDecl type = getTypeAccess().type(); 099 if(!expr.isUnknown()) { 100 if(!expr.castingConversionTo(type)) 101 error(expr.typeName() + " can not be cast into " + type.typeName()); 102 if(!getTypeAccess().isTypeAccess()) 103 error("" + getTypeAccess() + " is not a type access in cast expression"); 104 } 105 } 106 /** 107 * @ast method 108 * @aspect CreateBCode 109 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CreateBCode.jrag:840 110 */ 111 public void createBCode(CodeGeneration gen) { 112 getExpr().createBCode(gen); 113 getExpr().type().emitCastTo(gen, type()); 114 } 115 /** 116 * @ast method 117 * @aspect UncheckedConversion 118 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/UncheckedConversion.jrag:35 119 */ 120 public void checkWarnings() { 121 if (!withinSuppressWarnings("unchecked")) 122 checkUncheckedConversion(getExpr().type(), getTypeAccess().type()); 123 } 124 /** 125 * @ast method 126 * 127 */ 128 public CastExpr() { 129 super(); 130 131 132 } 133 /** 134 * Initializes the child array to the correct size. 135 * Initializes List and Opt nta children. 136 * @apilevel internal 137 * @ast method 138 * @ast method 139 * 140 */ 141 public void init$Children() { 142 children = new ASTNode[2]; 143 } 144 /** 145 * @ast method 146 * 147 */ 148 public CastExpr(Access p0, Expr p1) { 149 setChild(p0, 0); 150 setChild(p1, 1); 151 } 152 /** 153 * @apilevel low-level 154 * @ast method 155 * 156 */ 157 protected int numChildren() { 158 return 2; 159 } 160 /** 161 * @apilevel internal 162 * @ast method 163 * 164 */ 165 public boolean mayHaveRewrite() { 166 return false; 167 } 168 /** 169 * Replaces the TypeAccess child. 170 * @param node The new node to replace the TypeAccess child. 171 * @apilevel high-level 172 * @ast method 173 * 174 */ 175 public void setTypeAccess(Access node) { 176 setChild(node, 0); 177 } 178 /** 179 * Retrieves the TypeAccess child. 180 * @return The current node used as the TypeAccess child. 181 * @apilevel high-level 182 * @ast method 183 * 184 */ 185 public Access getTypeAccess() { 186 return (Access)getChild(0); 187 } 188 /** 189 * Retrieves the TypeAccess child. 190 * <p><em>This method does not invoke AST transformations.</em></p> 191 * @return The current node used as the TypeAccess child. 192 * @apilevel low-level 193 * @ast method 194 * 195 */ 196 public Access getTypeAccessNoTransform() { 197 return (Access)getChildNoTransform(0); 198 } 199 /** 200 * Replaces the Expr child. 201 * @param node The new node to replace the Expr child. 202 * @apilevel high-level 203 * @ast method 204 * 205 */ 206 public void setExpr(Expr node) { 207 setChild(node, 1); 208 } 209 /** 210 * Retrieves the Expr child. 211 * @return The current node used as the Expr child. 212 * @apilevel high-level 213 * @ast method 214 * 215 */ 216 public Expr getExpr() { 217 return (Expr)getChild(1); 218 } 219 /** 220 * Retrieves the Expr child. 221 * <p><em>This method does not invoke AST transformations.</em></p> 222 * @return The current node used as the Expr child. 223 * @apilevel low-level 224 * @ast method 225 * 226 */ 227 public Expr getExprNoTransform() { 228 return (Expr)getChildNoTransform(1); 229 } 230 /** 231 * @attribute syn 232 * @aspect ConstantExpression 233 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/ConstantExpression.jrag:91 234 */ 235 public Constant constant() { 236 ASTNode$State state = state(); 237 try { return type().cast(getExpr().constant()); } 238 finally { 239 } 240 } 241 /** 242 * @attribute syn 243 * @aspect ConstantExpression 244 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/ConstantExpression.jrag:336 245 */ 246 public boolean isConstant() { 247 ASTNode$State state = state(); 248 try { return getExpr().isConstant() && 249 (getTypeAccess().type().isPrimitive() || getTypeAccess().type().isString()); } 250 finally { 251 } 252 } 253 /** 254 * @attribute syn 255 * @aspect DA 256 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:235 257 */ 258 public boolean isDAafter(Variable v) { 259 ASTNode$State state = state(); 260 try { return getExpr().isDAafter(v); } 261 finally { 262 } 263 } 264 /** 265 * @attribute syn 266 * @aspect DU 267 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:694 268 */ 269 public boolean isDUafter(Variable v) { 270 ASTNode$State state = state(); 271 try { return getExpr().isDUafter(v); } 272 finally { 273 } 274 } 275 /** 276 * @attribute syn 277 * @aspect AccessTypes 278 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ResolveAmbiguousNames.jrag:25 279 */ 280 public boolean isSuperAccess() { 281 ASTNode$State state = state(); 282 try { return getExpr().isSuperAccess(); } 283 finally { 284 } 285 } 286 /** 287 * @attribute syn 288 * @aspect AccessTypes 289 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ResolveAmbiguousNames.jrag:31 290 */ 291 public boolean isThisAccess() { 292 ASTNode$State state = state(); 293 try { return getExpr().isThisAccess(); } 294 finally { 295 } 296 } 297 /** 298 * @apilevel internal 299 */ 300 protected boolean type_computed = false; 301 /** 302 * @apilevel internal 303 */ 304 protected TypeDecl type_value; 305 /** 306 * @attribute syn 307 * @aspect TypeAnalysis 308 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:320 309 */ 310 @SuppressWarnings({"unchecked", "cast"}) 311 public TypeDecl type() { 312 if(type_computed) { 313 return type_value; 314 } 315 ASTNode$State state = state(); 316 int num = state.boundariesCrossed; 317 boolean isFinal = this.is$Final(); 318 type_value = type_compute(); 319 if(isFinal && num == state().boundariesCrossed){ type_computed = true; } 320 return type_value; 321 } 322 /** 323 * @apilevel internal 324 */ 325 private TypeDecl type_compute() { return getTypeAccess().type(); } 326 /** 327 * @attribute syn 328 * @aspect TypeHierarchyCheck 329 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeHierarchyCheck.jrag:150 330 */ 331 public boolean staticContextQualifier() { 332 ASTNode$State state = state(); 333 try { return getExpr().staticContextQualifier(); } 334 finally { 335 } 336 } 337 /** 338 * @attribute inh 339 * @aspect SuppressWarnings 340 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/SuppressWarnings.jrag:16 341 */ 342 @SuppressWarnings({"unchecked", "cast"}) 343 public boolean withinSuppressWarnings(String s) { 344 ASTNode$State state = state(); 345 boolean withinSuppressWarnings_String_value = getParent().Define_boolean_withinSuppressWarnings(this, null, s); 346 return withinSuppressWarnings_String_value; 347 } 348 /** 349 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/SyntacticClassification.jrag:88 350 * @apilevel internal 351 */ 352 public NameType Define_NameType_nameType(ASTNode caller, ASTNode child) { 353 if(caller == getTypeAccessNoTransform()) { 354 return NameType.TYPE_NAME; 355 } 356 else { return getParent().Define_NameType_nameType(this, caller); 357 } 358 } 359 /** 360 * @apilevel internal 361 */ 362 public ASTNode rewriteTo() { 363 return super.rewriteTo(); 364 } 365 }