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:135 027 * @production PreDecExpr : {@link Unary}; 028 029 */ 030 public class PreDecExpr extends Unary implements Cloneable { 031 /** 032 * @aspect DefiniteAssignment 033 * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:104 034 */ 035 public void definiteAssignment() { 036 if (getOperand().isVariable()) { 037 Variable v = getOperand().varDecl(); 038 if (v != null && v.isFinal()) { 039 error("++ and -- can not be applied to final variable " + v); 040 } 041 } 042 } 043 /** 044 * @aspect DA 045 * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:537 046 */ 047 protected boolean checkDUeverywhere(Variable v) { 048 if (getOperand().isVariable() && getOperand().varDecl() == v) { 049 if (!isDAbefore(v)) { 050 return false; 051 } 052 } 053 return super.checkDUeverywhere(v); 054 } 055 /** 056 * @aspect TypeCheck 057 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeCheck.jrag:363 058 */ 059 public void typeCheck() { 060 if (!getOperand().isVariable()) { 061 error("prefix decrement expression only work on variables"); 062 } else if (!getOperand().type().isNumericType()) { 063 error("unary decrement only operates on numeric types"); 064 } 065 } 066 /** 067 * @aspect CreateBCode 068 * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:963 069 */ 070 public void createBCode(CodeGeneration gen) { emitPrefix(gen, -1); } 071 /** 072 * @declaredat ASTNode:1 073 */ 074 public PreDecExpr() { 075 super(); 076 } 077 /** 078 * Initializes the child array to the correct size. 079 * Initializes List and Opt nta children. 080 * @apilevel internal 081 * @ast method 082 * @declaredat ASTNode:10 083 */ 084 public void init$Children() { 085 children = new ASTNode[1]; 086 } 087 /** 088 * @declaredat ASTNode:13 089 */ 090 public PreDecExpr(Expr p0) { 091 setChild(p0, 0); 092 } 093 /** 094 * @apilevel low-level 095 * @declaredat ASTNode:19 096 */ 097 protected int numChildren() { 098 return 1; 099 } 100 /** 101 * @apilevel internal 102 * @declaredat ASTNode:25 103 */ 104 public boolean mayHaveRewrite() { 105 return false; 106 } 107 /** 108 * @apilevel internal 109 * @declaredat ASTNode:31 110 */ 111 public void flushAttrCache() { 112 super.flushAttrCache(); 113 stmtCompatible_reset(); 114 } 115 /** 116 * @apilevel internal 117 * @declaredat ASTNode:38 118 */ 119 public void flushCollectionCache() { 120 super.flushCollectionCache(); 121 } 122 /** 123 * @apilevel internal 124 * @declaredat ASTNode:44 125 */ 126 public void flushRewriteCache() { 127 super.flushRewriteCache(); 128 } 129 /** 130 * @apilevel internal 131 * @declaredat ASTNode:50 132 */ 133 public PreDecExpr clone() throws CloneNotSupportedException { 134 PreDecExpr node = (PreDecExpr) super.clone(); 135 return node; 136 } 137 /** 138 * @apilevel internal 139 * @declaredat ASTNode:57 140 */ 141 public PreDecExpr copy() { 142 try { 143 PreDecExpr node = (PreDecExpr) clone(); 144 node.parent = null; 145 if (children != null) { 146 node.children = (ASTNode[]) children.clone(); 147 } 148 return node; 149 } catch (CloneNotSupportedException e) { 150 throw new Error("Error: clone not supported for " + getClass().getName()); 151 } 152 } 153 /** 154 * Create a deep copy of the AST subtree at this node. 155 * The copy is dangling, i.e. has no parent. 156 * @return dangling copy of the subtree at this node 157 * @apilevel low-level 158 * @deprecated Please use treeCopy or treeCopyNoTransform instead 159 * @declaredat ASTNode:76 160 */ 161 @Deprecated 162 public PreDecExpr fullCopy() { 163 return treeCopyNoTransform(); 164 } 165 /** 166 * Create a deep copy of the AST subtree at this node. 167 * The copy is dangling, i.e. has no parent. 168 * @return dangling copy of the subtree at this node 169 * @apilevel low-level 170 * @declaredat ASTNode:86 171 */ 172 public PreDecExpr treeCopyNoTransform() { 173 PreDecExpr tree = (PreDecExpr) copy(); 174 if (children != null) { 175 for (int i = 0; i < children.length; ++i) { 176 ASTNode child = (ASTNode) children[i]; 177 if (child != null) { 178 child = child.treeCopyNoTransform(); 179 tree.setChild(child, i); 180 } 181 } 182 } 183 return tree; 184 } 185 /** 186 * Create a deep copy of the AST subtree at this node. 187 * The subtree of this node is traversed to trigger rewrites before copy. 188 * The copy is dangling, i.e. has no parent. 189 * @return dangling copy of the subtree at this node 190 * @apilevel low-level 191 * @declaredat ASTNode:106 192 */ 193 public PreDecExpr treeCopy() { 194 doFullTraversal(); 195 return treeCopyNoTransform(); 196 } 197 /** 198 * @apilevel internal 199 * @declaredat ASTNode:113 200 */ 201 protected boolean is$Equal(ASTNode node) { 202 return super.is$Equal(node); 203 } 204 /** 205 * Replaces the Operand child. 206 * @param node The new node to replace the Operand child. 207 * @apilevel high-level 208 */ 209 public void setOperand(Expr node) { 210 setChild(node, 0); 211 } 212 /** 213 * Retrieves the Operand child. 214 * @return The current node used as the Operand child. 215 * @apilevel high-level 216 */ 217 @ASTNodeAnnotation.Child(name="Operand") 218 public Expr getOperand() { 219 return (Expr) getChild(0); 220 } 221 /** 222 * Retrieves the Operand child. 223 * <p><em>This method does not invoke AST transformations.</em></p> 224 * @return The current node used as the Operand child. 225 * @apilevel low-level 226 */ 227 public Expr getOperandNoTransform() { 228 return (Expr) getChildNoTransform(0); 229 } 230 /** 231 * @attribute syn 232 * @aspect PrettyPrintUtil 233 * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:310 234 */ 235 @ASTNodeAnnotation.Attribute 236 public String printPreOp() { 237 String printPreOp_value = "--"; 238 239 return printPreOp_value; 240 } 241 /** 242 * @attribute syn 243 * @aspect CreateBCode 244 * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:251 245 */ 246 @ASTNodeAnnotation.Attribute 247 public boolean needsPop() { 248 boolean needsPop_value = false; 249 250 return needsPop_value; 251 } 252 /** 253 * @attribute syn 254 * @aspect PreciseRethrow 255 * @declaredat /home/jesper/git/extendj/java7/frontend/PreciseRethrow.jrag:149 256 */ 257 @ASTNodeAnnotation.Attribute 258 public boolean modifiedInScope(Variable var) { 259 boolean modifiedInScope_Variable_value = getOperand().isVariable(var); 260 261 return modifiedInScope_Variable_value; 262 } 263 /** 264 * @apilevel internal 265 */ 266 protected boolean stmtCompatible_computed = false; 267 /** 268 * @apilevel internal 269 */ 270 protected boolean stmtCompatible_value; 271 /** 272 * @apilevel internal 273 */ 274 private void stmtCompatible_reset() { 275 stmtCompatible_computed = false; 276 } 277 /** 278 * @attribute syn 279 * @aspect StmtCompatible 280 * @declaredat /home/jesper/git/extendj/java8/frontend/LambdaExpr.jrag:144 281 */ 282 @ASTNodeAnnotation.Attribute 283 public boolean stmtCompatible() { 284 ASTNode$State state = state(); 285 if (stmtCompatible_computed) { 286 return stmtCompatible_value; 287 } 288 boolean intermediate = state.INTERMEDIATE_VALUE; 289 state.INTERMEDIATE_VALUE = false; 290 int num = state.boundariesCrossed; 291 boolean isFinal = this.is$Final(); 292 stmtCompatible_value = true; 293 if (isFinal && num == state().boundariesCrossed) { 294 stmtCompatible_computed = true; 295 } else { 296 } 297 state.INTERMEDIATE_VALUE |= intermediate; 298 299 return stmtCompatible_value; 300 } 301 /** 302 * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:37 303 * @apilevel internal 304 */ 305 public boolean Define_isDest(ASTNode caller, ASTNode child) { 306 if (caller == getOperandNoTransform()) { 307 // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:69 308 return true; 309 } 310 else { 311 return getParent().Define_isDest(this, caller); 312 } 313 } 314 protected boolean canDefine_isDest(ASTNode caller, ASTNode child) { 315 return true; 316 } 317 /** 318 * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:71 319 * @apilevel internal 320 */ 321 public boolean Define_isIncOrDec(ASTNode caller, ASTNode child) { 322 if (caller == getOperandNoTransform()) { 323 // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:78 324 return true; 325 } 326 else { 327 return getParent().Define_isIncOrDec(this, caller); 328 } 329 } 330 protected boolean canDefine_isIncOrDec(ASTNode caller, ASTNode child) { 331 return true; 332 } 333 /** 334 * @apilevel internal 335 */ 336 public ASTNode rewriteTo() { 337 return super.rewriteTo(); 338 } 339 }