001 /* This file was generated with JastAdd2 (http://jastadd.org) version 2.1.13-12-g880e696 */ 002 package org.extendj.ast; 003 004 import java.util.HashSet; 005 import java.io.File; 006 import java.util.Set; 007 import java.util.Collections; 008 import java.util.Collection; 009 import java.util.ArrayList; 010 import beaver.*; 011 import java.util.*; 012 import java.io.ByteArrayOutputStream; 013 import java.io.PrintStream; 014 import java.lang.reflect.InvocationTargetException; 015 import java.lang.reflect.Method; 016 import org.jastadd.util.*; 017 import java.util.zip.*; 018 import java.io.*; 019 import org.jastadd.util.PrettyPrintable; 020 import org.jastadd.util.PrettyPrinter; 021 import java.io.FileNotFoundException; 022 import java.io.BufferedInputStream; 023 import java.io.DataInputStream; 024 /** 025 * @ast node 026 * @declaredat /home/jesper/git/extendj/java4/grammar/Java.ast:133 027 * @production Unary : {@link Expr} ::= <span class="component">Operand:{@link Expr}</span>; 028 029 */ 030 public abstract class Unary extends Expr implements Cloneable { 031 /** 032 * @aspect Java4PrettyPrint 033 * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrint.jadd:230 034 */ 035 public void prettyPrint(PrettyPrinter out) { 036 out.print(printPreOp()); 037 out.print(getOperand()); 038 out.print(printPostOp()); 039 } 040 /** 041 * @aspect CreateBCode 042 * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:915 043 */ 044 public void createBCode(CodeGeneration gen) { 045 super.createBCode(gen); 046 emitOperation(gen); 047 } 048 /** 049 * @aspect AutoBoxingCodegen 050 * @declaredat /home/jesper/git/extendj/java5/backend/AutoBoxingCodegen.jrag:346 051 */ 052 protected void boxingGen(CodeGeneration gen) { 053 getOperand().createBCode(gen); 054 TypeDecl type = getOperand().type(); 055 if (type.isReferenceType()) { 056 type.emitCastTo(gen, type()); 057 } 058 emitOperation(gen); 059 } 060 /** 061 * @declaredat ASTNode:1 062 */ 063 public Unary() { 064 super(); 065 } 066 /** 067 * Initializes the child array to the correct size. 068 * Initializes List and Opt nta children. 069 * @apilevel internal 070 * @ast method 071 * @declaredat ASTNode:10 072 */ 073 public void init$Children() { 074 children = new ASTNode[1]; 075 } 076 /** 077 * @declaredat ASTNode:13 078 */ 079 public Unary(Expr p0) { 080 setChild(p0, 0); 081 } 082 /** 083 * @apilevel low-level 084 * @declaredat ASTNode:19 085 */ 086 protected int numChildren() { 087 return 1; 088 } 089 /** 090 * @apilevel internal 091 * @declaredat ASTNode:25 092 */ 093 public boolean mayHaveRewrite() { 094 return false; 095 } 096 /** 097 * @apilevel internal 098 * @declaredat ASTNode:31 099 */ 100 public void flushAttrCache() { 101 super.flushAttrCache(); 102 type_reset(); 103 } 104 /** 105 * @apilevel internal 106 * @declaredat ASTNode:38 107 */ 108 public void flushCollectionCache() { 109 super.flushCollectionCache(); 110 } 111 /** 112 * @apilevel internal 113 * @declaredat ASTNode:44 114 */ 115 public void flushRewriteCache() { 116 super.flushRewriteCache(); 117 } 118 /** 119 * @apilevel internal 120 * @declaredat ASTNode:50 121 */ 122 public Unary clone() throws CloneNotSupportedException { 123 Unary node = (Unary) super.clone(); 124 return node; 125 } 126 /** 127 * Create a deep copy of the AST subtree at this node. 128 * The copy is dangling, i.e. has no parent. 129 * @return dangling copy of the subtree at this node 130 * @apilevel low-level 131 * @deprecated Please use treeCopy or treeCopyNoTransform instead 132 * @declaredat ASTNode:61 133 */ 134 @Deprecated 135 public abstract Unary fullCopy(); 136 /** 137 * Create a deep copy of the AST subtree at this node. 138 * The copy is dangling, i.e. has no parent. 139 * @return dangling copy of the subtree at this node 140 * @apilevel low-level 141 * @declaredat ASTNode:69 142 */ 143 public abstract Unary treeCopyNoTransform(); 144 /** 145 * Create a deep copy of the AST subtree at this node. 146 * The subtree of this node is traversed to trigger rewrites before copy. 147 * The copy is dangling, i.e. has no parent. 148 * @return dangling copy of the subtree at this node 149 * @apilevel low-level 150 * @declaredat ASTNode:77 151 */ 152 public abstract Unary treeCopy(); 153 /** 154 * Replaces the Operand child. 155 * @param node The new node to replace the Operand child. 156 * @apilevel high-level 157 */ 158 public void setOperand(Expr node) { 159 setChild(node, 0); 160 } 161 /** 162 * Retrieves the Operand child. 163 * @return The current node used as the Operand child. 164 * @apilevel high-level 165 */ 166 @ASTNodeAnnotation.Child(name="Operand") 167 public Expr getOperand() { 168 return (Expr) getChild(0); 169 } 170 /** 171 * Retrieves the Operand child. 172 * <p><em>This method does not invoke AST transformations.</em></p> 173 * @return The current node used as the Operand child. 174 * @apilevel low-level 175 */ 176 public Expr getOperandNoTransform() { 177 return (Expr) getChildNoTransform(0); 178 } 179 /** 180 * @aspect AutoBoxingCodegen 181 * @declaredat /home/jesper/git/extendj/java5/backend/AutoBoxingCodegen.jrag:250 182 */ 183 public void emitPostfix(CodeGeneration gen, int constant) { 184 Expr operand = getOperand(); 185 while (operand instanceof ParExpr) { 186 operand = ((ParExpr) operand).getExpr(); 187 } 188 Access access = ((Access) operand).lastAccess(); 189 access.createAssignLoadDest(gen); 190 if (needsPush()) { 191 access.createPushAssignmentResult(gen); 192 } 193 TypeDecl type = access.type().binaryNumericPromotion(typeInt()); 194 access.type().emitCastTo(gen, type); // Added for AutoBoxing 195 type.emitPushConstant(gen, constant); 196 type.add(gen); 197 type.emitCastTo(gen, access.type()); 198 access.emitStore(gen); 199 } 200 /** 201 * @aspect AutoBoxingCodegen 202 * @declaredat /home/jesper/git/extendj/java5/backend/AutoBoxingCodegen.jrag:270 203 */ 204 public void emitPrefix(CodeGeneration gen, int constant) { 205 Expr operand = getOperand(); 206 while (operand instanceof ParExpr) { 207 operand = ((ParExpr) operand).getExpr(); 208 } 209 Access access = ((Access) operand).lastAccess(); 210 access.createAssignLoadDest(gen); 211 TypeDecl type = access.type().binaryNumericPromotion(typeInt()); 212 access.type().emitCastTo(gen, type); // Added for AutoBoxing 213 type.emitPushConstant(gen, constant); 214 type.add(gen); 215 type.emitCastTo(gen, access.type()); 216 if (needsPush()) { 217 access.createPushAssignmentResult(gen); 218 } 219 access.emitStore(gen); 220 } 221 /** 222 * @attribute syn 223 * @aspect DA 224 * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:259 225 */ 226 @ASTNodeAnnotation.Attribute 227 public boolean isDAafter(Variable v) { 228 boolean isDAafter_Variable_value = getOperand().isDAafter(v); 229 230 return isDAafter_Variable_value; 231 } 232 /** 233 * @attribute syn 234 * @aspect DU 235 * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:783 236 */ 237 @ASTNodeAnnotation.Attribute 238 public boolean isDUafter(Variable v) { 239 boolean isDUafter_Variable_value = getOperand().isDUafter(v); 240 241 return isDUafter_Variable_value; 242 } 243 /** 244 * @attribute syn 245 * @aspect PrettyPrintUtil 246 * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:306 247 */ 248 @ASTNodeAnnotation.Attribute 249 public String printPostOp() { 250 String printPostOp_value = ""; 251 252 return printPostOp_value; 253 } 254 /** 255 * @attribute syn 256 * @aspect PrettyPrintUtil 257 * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:310 258 */ 259 @ASTNodeAnnotation.Attribute 260 public String printPreOp() { 261 String printPreOp_value = ""; 262 263 return printPreOp_value; 264 } 265 /** 266 * @apilevel internal 267 */ 268 protected boolean type_computed = false; 269 /** 270 * @apilevel internal 271 */ 272 protected TypeDecl type_value; 273 /** 274 * @apilevel internal 275 */ 276 private void type_reset() { 277 type_computed = false; 278 type_value = null; 279 } 280 /** 281 * @attribute syn 282 * @aspect TypeAnalysis 283 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:302 284 */ 285 @ASTNodeAnnotation.Attribute 286 public TypeDecl type() { 287 ASTNode$State state = state(); 288 if (type_computed) { 289 return type_value; 290 } 291 boolean intermediate = state.INTERMEDIATE_VALUE; 292 state.INTERMEDIATE_VALUE = false; 293 int num = state.boundariesCrossed; 294 boolean isFinal = this.is$Final(); 295 type_value = getOperand().type(); 296 if (isFinal && num == state().boundariesCrossed) { 297 type_computed = true; 298 } else { 299 } 300 state.INTERMEDIATE_VALUE |= intermediate; 301 302 return type_value; 303 } 304 /** 305 * @attribute syn 306 * @aspect PreciseRethrow 307 * @declaredat /home/jesper/git/extendj/java7/frontend/PreciseRethrow.jrag:149 308 */ 309 @ASTNodeAnnotation.Attribute 310 public boolean modifiedInScope(Variable var) { 311 boolean modifiedInScope_Variable_value = getOperand().modifiedInScope(var); 312 313 return modifiedInScope_Variable_value; 314 } 315 /** 316 * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:47 317 * @apilevel internal 318 */ 319 public boolean Define_isSource(ASTNode caller, ASTNode child) { 320 if (caller == getOperandNoTransform()) { 321 // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:66 322 return true; 323 } 324 else { 325 return getParent().Define_isSource(this, caller); 326 } 327 } 328 protected boolean canDefine_isSource(ASTNode caller, ASTNode child) { 329 return true; 330 } 331 /** 332 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:196 333 * @apilevel internal 334 */ 335 public boolean Define_assignmentContext(ASTNode caller, ASTNode child) { 336 if (caller == getOperandNoTransform()) { 337 // @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:246 338 return false; 339 } 340 else { 341 return getParent().Define_assignmentContext(this, caller); 342 } 343 } 344 protected boolean canDefine_assignmentContext(ASTNode caller, ASTNode child) { 345 return true; 346 } 347 /** 348 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:197 349 * @apilevel internal 350 */ 351 public boolean Define_invocationContext(ASTNode caller, ASTNode child) { 352 if (caller == getOperandNoTransform()) { 353 // @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:247 354 return false; 355 } 356 else { 357 return getParent().Define_invocationContext(this, caller); 358 } 359 } 360 protected boolean canDefine_invocationContext(ASTNode caller, ASTNode child) { 361 return true; 362 } 363 /** 364 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:198 365 * @apilevel internal 366 */ 367 public boolean Define_castContext(ASTNode caller, ASTNode child) { 368 if (caller == getOperandNoTransform()) { 369 // @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:248 370 return false; 371 } 372 else { 373 return getParent().Define_castContext(this, caller); 374 } 375 } 376 protected boolean canDefine_castContext(ASTNode caller, ASTNode child) { 377 return true; 378 } 379 /** 380 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:199 381 * @apilevel internal 382 */ 383 public boolean Define_stringContext(ASTNode caller, ASTNode child) { 384 if (caller == getOperandNoTransform()) { 385 // @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:249 386 return false; 387 } 388 else { 389 return getParent().Define_stringContext(this, caller); 390 } 391 } 392 protected boolean canDefine_stringContext(ASTNode caller, ASTNode child) { 393 return true; 394 } 395 /** 396 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:200 397 * @apilevel internal 398 */ 399 public boolean Define_numericContext(ASTNode caller, ASTNode child) { 400 if (caller == getOperandNoTransform()) { 401 // @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:250 402 return false; 403 } 404 else { 405 return getParent().Define_numericContext(this, caller); 406 } 407 } 408 protected boolean canDefine_numericContext(ASTNode caller, ASTNode child) { 409 return true; 410 } 411 /** 412 * @apilevel internal 413 */ 414 public ASTNode rewriteTo() { 415 return super.rewriteTo(); 416 } 417 }