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 DivExpr : {@link MultiplicativeExpr}; 015 * @ast node 016 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/java.ast:155 017 */ 018 public class DivExpr extends MultiplicativeExpr 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 DivExpr clone() throws CloneNotSupportedException { 034 DivExpr node = (DivExpr)super.clone(); 035 node.isConstant_visited = -1; 036 node.isConstant_computed = false; 037 node.isConstant_initialized = false; 038 node.in$Circle(false); 039 node.is$Final(false); 040 return node; 041 } 042 /** 043 * @apilevel internal 044 */ 045 @SuppressWarnings({"unchecked", "cast"}) 046 public DivExpr copy() { 047 048 try { 049 DivExpr node = (DivExpr) clone(); 050 node.parent = null; 051 if(children != null) 052 node.children = (ASTNode[]) children.clone(); 053 054 return node; 055 } catch (CloneNotSupportedException e) { 056 throw new Error("Error: clone not supported for " + getClass().getName()); 057 } 058 059 }/** 060 * Create a deep copy of the AST subtree at this node. 061 * The copy is dangling, i.e. has no parent. 062 * @return dangling copy of the subtree at this node 063 * @apilevel low-level 064 */ 065 @SuppressWarnings({"unchecked", "cast"}) 066 public DivExpr fullCopy() { 067 068 DivExpr tree = (DivExpr) copy(); 069 if (children != null) { 070 for (int i = 0; i < children.length; ++i) { 071 072 ASTNode child = (ASTNode) children[i]; 073 if(child != null) { 074 child = child.fullCopy(); 075 tree.setChild(child, i); 076 } 077 } 078 } 079 return tree; 080 081 } /** 082 * @ast method 083 * @aspect CodeGenerationBinaryOperations 084 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:1027 085 */ 086 void emitOperation(CodeGeneration gen) { type().div(gen); } 087 /** 088 * @ast method 089 * 090 */ 091 public DivExpr() { 092 super(); 093 094 095 } 096 /** 097 * Initializes the child array to the correct size. 098 * Initializes List and Opt nta children. 099 * @apilevel internal 100 * @ast method 101 * @ast method 102 * 103 */ 104 public void init$Children() { 105 children = new ASTNode[2]; 106 } 107 /** 108 * @ast method 109 * 110 */ 111 public DivExpr(Expr p0, Expr p1) { 112 setChild(p0, 0); 113 setChild(p1, 1); 114 } 115 /** 116 * @apilevel low-level 117 * @ast method 118 * 119 */ 120 protected int numChildren() { 121 return 2; 122 } 123 /** 124 * @apilevel internal 125 * @ast method 126 * 127 */ 128 public boolean mayHaveRewrite() { 129 return false; 130 } 131 /** 132 * Replaces the LeftOperand child. 133 * @param node The new node to replace the LeftOperand child. 134 * @apilevel high-level 135 * @ast method 136 * 137 */ 138 public void setLeftOperand(Expr node) { 139 setChild(node, 0); 140 } 141 /** 142 * Retrieves the LeftOperand child. 143 * @return The current node used as the LeftOperand child. 144 * @apilevel high-level 145 * @ast method 146 * 147 */ 148 public Expr getLeftOperand() { 149 return (Expr)getChild(0); 150 } 151 /** 152 * Retrieves the LeftOperand child. 153 * <p><em>This method does not invoke AST transformations.</em></p> 154 * @return The current node used as the LeftOperand child. 155 * @apilevel low-level 156 * @ast method 157 * 158 */ 159 public Expr getLeftOperandNoTransform() { 160 return (Expr)getChildNoTransform(0); 161 } 162 /** 163 * Replaces the RightOperand child. 164 * @param node The new node to replace the RightOperand child. 165 * @apilevel high-level 166 * @ast method 167 * 168 */ 169 public void setRightOperand(Expr node) { 170 setChild(node, 1); 171 } 172 /** 173 * Retrieves the RightOperand child. 174 * @return The current node used as the RightOperand child. 175 * @apilevel high-level 176 * @ast method 177 * 178 */ 179 public Expr getRightOperand() { 180 return (Expr)getChild(1); 181 } 182 /** 183 * Retrieves the RightOperand child. 184 * <p><em>This method does not invoke AST transformations.</em></p> 185 * @return The current node used as the RightOperand child. 186 * @apilevel low-level 187 * @ast method 188 * 189 */ 190 public Expr getRightOperandNoTransform() { 191 return (Expr)getChildNoTransform(1); 192 } 193 /** 194 * @attribute syn 195 * @aspect ConstantExpression 196 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/ConstantExpression.jrag:91 197 */ 198 public Constant constant() { 199 ASTNode$State state = state(); 200 try { return type().div(getLeftOperand().constant(), getRightOperand().constant()); } 201 finally { 202 } 203 } 204 /** 205 * @apilevel internal 206 */ 207 protected int isConstant_visited = -1; 208 /** 209 * @apilevel internal 210 */ 211 protected boolean isConstant_computed = false; 212 /** 213 * @apilevel internal 214 */ 215 protected boolean isConstant_initialized = false; 216 /** 217 * @apilevel internal 218 */ 219 protected boolean isConstant_value; 220 /** 221 * @attribute syn 222 * @aspect ConstantExpression 223 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/ConstantExpression.jrag:351 224 */ 225 @SuppressWarnings({"unchecked", "cast"}) 226 public boolean isConstant() { 227 if(isConstant_computed) { 228 return isConstant_value; 229 } 230 ASTNode$State state = state(); 231 if (!isConstant_initialized) { 232 isConstant_initialized = true; 233 isConstant_value = false; 234 } 235 if (!state.IN_CIRCLE) { 236 state.IN_CIRCLE = true; 237 int num = state.boundariesCrossed; 238 boolean isFinal = this.is$Final(); 239 do { 240 isConstant_visited = state.CIRCLE_INDEX; 241 state.CHANGE = false; 242 boolean new_isConstant_value = isConstant_compute(); 243 if (new_isConstant_value!=isConstant_value) 244 state.CHANGE = true; 245 isConstant_value = new_isConstant_value; 246 state.CIRCLE_INDEX++; 247 } while (state.CHANGE); 248 if(isFinal && num == state().boundariesCrossed) { 249 isConstant_computed = true; 250 } 251 else { 252 state.RESET_CYCLE = true; 253 isConstant_compute(); 254 state.RESET_CYCLE = false; 255 isConstant_computed = false; 256 isConstant_initialized = false; 257 } 258 state.IN_CIRCLE = false; 259 return isConstant_value; 260 } 261 if(isConstant_visited != state.CIRCLE_INDEX) { 262 isConstant_visited = state.CIRCLE_INDEX; 263 if (state.RESET_CYCLE) { 264 isConstant_computed = false; 265 isConstant_initialized = false; 266 isConstant_visited = -1; 267 return isConstant_value; 268 } 269 boolean new_isConstant_value = isConstant_compute(); 270 if (new_isConstant_value!=isConstant_value) 271 state.CHANGE = true; 272 isConstant_value = new_isConstant_value; 273 return isConstant_value; 274 } 275 return isConstant_value; 276 } 277 /** 278 * @apilevel internal 279 */ 280 private boolean isConstant_compute() { return getLeftOperand().isConstant() && getRightOperand().isConstant() && !(getRightOperand().type().isInt() && getRightOperand().constant().intValue() == 0); } 281 /** 282 * @attribute syn 283 * @aspect PrettyPrint 284 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/PrettyPrint.jadd:400 285 */ 286 public String printOp() { 287 ASTNode$State state = state(); 288 try { return " / "; } 289 finally { 290 } 291 } 292 /** 293 * @apilevel internal 294 */ 295 public ASTNode rewriteTo() { 296 return super.rewriteTo(); 297 } 298 }