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:50 027 * @production NumericType : {@link PrimitiveType}; 028 029 */ 030 public abstract class NumericType extends PrimitiveType implements Cloneable { 031 /** 032 * @declaredat ASTNode:1 033 */ 034 public NumericType() { 035 super(); 036 } 037 /** 038 * Initializes the child array to the correct size. 039 * Initializes List and Opt nta children. 040 * @apilevel internal 041 * @ast method 042 * @declaredat ASTNode:10 043 */ 044 public void init$Children() { 045 children = new ASTNode[3]; 046 setChild(new Opt(), 1); 047 setChild(new List(), 2); 048 } 049 /** 050 * @declaredat ASTNode:15 051 */ 052 public NumericType(Modifiers p0, String p1, Opt<Access> p2, List<BodyDecl> p3) { 053 setChild(p0, 0); 054 setID(p1); 055 setChild(p2, 1); 056 setChild(p3, 2); 057 } 058 /** 059 * @declaredat ASTNode:21 060 */ 061 public NumericType(Modifiers p0, beaver.Symbol p1, Opt<Access> p2, List<BodyDecl> p3) { 062 setChild(p0, 0); 063 setID(p1); 064 setChild(p2, 1); 065 setChild(p3, 2); 066 } 067 /** 068 * @apilevel low-level 069 * @declaredat ASTNode:30 070 */ 071 protected int numChildren() { 072 return 3; 073 } 074 /** 075 * @apilevel internal 076 * @declaredat ASTNode:36 077 */ 078 public boolean mayHaveRewrite() { 079 return false; 080 } 081 /** 082 * @apilevel internal 083 * @declaredat ASTNode:42 084 */ 085 public void flushAttrCache() { 086 super.flushAttrCache(); 087 unaryNumericPromotion_reset(); 088 binaryNumericPromotion_TypeDecl_reset(); 089 } 090 /** 091 * @apilevel internal 092 * @declaredat ASTNode:50 093 */ 094 public void flushCollectionCache() { 095 super.flushCollectionCache(); 096 } 097 /** 098 * @apilevel internal 099 * @declaredat ASTNode:56 100 */ 101 public void flushRewriteCache() { 102 super.flushRewriteCache(); 103 } 104 /** 105 * @apilevel internal 106 * @declaredat ASTNode:62 107 */ 108 public NumericType clone() throws CloneNotSupportedException { 109 NumericType node = (NumericType) super.clone(); 110 return node; 111 } 112 /** 113 * Create a deep copy of the AST subtree at this node. 114 * The copy is dangling, i.e. has no parent. 115 * @return dangling copy of the subtree at this node 116 * @apilevel low-level 117 * @deprecated Please use treeCopy or treeCopyNoTransform instead 118 * @declaredat ASTNode:73 119 */ 120 @Deprecated 121 public abstract NumericType fullCopy(); 122 /** 123 * Create a deep copy of the AST subtree at this node. 124 * The copy is dangling, i.e. has no parent. 125 * @return dangling copy of the subtree at this node 126 * @apilevel low-level 127 * @declaredat ASTNode:81 128 */ 129 public abstract NumericType treeCopyNoTransform(); 130 /** 131 * Create a deep copy of the AST subtree at this node. 132 * The subtree of this node is traversed to trigger rewrites before copy. 133 * The copy is dangling, i.e. has no parent. 134 * @return dangling copy of the subtree at this node 135 * @apilevel low-level 136 * @declaredat ASTNode:89 137 */ 138 public abstract NumericType treeCopy(); 139 /** 140 * Replaces the Modifiers child. 141 * @param node The new node to replace the Modifiers child. 142 * @apilevel high-level 143 */ 144 public void setModifiers(Modifiers node) { 145 setChild(node, 0); 146 } 147 /** 148 * Retrieves the Modifiers child. 149 * @return The current node used as the Modifiers child. 150 * @apilevel high-level 151 */ 152 @ASTNodeAnnotation.Child(name="Modifiers") 153 public Modifiers getModifiers() { 154 return (Modifiers) getChild(0); 155 } 156 /** 157 * Retrieves the Modifiers child. 158 * <p><em>This method does not invoke AST transformations.</em></p> 159 * @return The current node used as the Modifiers child. 160 * @apilevel low-level 161 */ 162 public Modifiers getModifiersNoTransform() { 163 return (Modifiers) getChildNoTransform(0); 164 } 165 /** 166 * Replaces the lexeme ID. 167 * @param value The new value for the lexeme ID. 168 * @apilevel high-level 169 */ 170 public void setID(String value) { 171 tokenString_ID = value; 172 } 173 /** 174 * JastAdd-internal setter for lexeme ID using the Beaver parser. 175 * @param symbol Symbol containing the new value for the lexeme ID 176 * @apilevel internal 177 */ 178 public void setID(beaver.Symbol symbol) { 179 if (symbol.value != null && !(symbol.value instanceof String)) 180 throw new UnsupportedOperationException("setID is only valid for String lexemes"); 181 tokenString_ID = (String)symbol.value; 182 IDstart = symbol.getStart(); 183 IDend = symbol.getEnd(); 184 } 185 /** 186 * Retrieves the value for the lexeme ID. 187 * @return The value for the lexeme ID. 188 * @apilevel high-level 189 */ 190 @ASTNodeAnnotation.Token(name="ID") 191 public String getID() { 192 return tokenString_ID != null ? tokenString_ID : ""; 193 } 194 /** 195 * Replaces the optional node for the SuperClass child. This is the <code>Opt</code> 196 * node containing the child SuperClass, not the actual child! 197 * @param opt The new node to be used as the optional node for the SuperClass child. 198 * @apilevel low-level 199 */ 200 public void setSuperClassOpt(Opt<Access> opt) { 201 setChild(opt, 1); 202 } 203 /** 204 * Replaces the (optional) SuperClass child. 205 * @param node The new node to be used as the SuperClass child. 206 * @apilevel high-level 207 */ 208 public void setSuperClass(Access node) { 209 getSuperClassOpt().setChild(node, 0); 210 } 211 /** 212 * Check whether the optional SuperClass child exists. 213 * @return {@code true} if the optional SuperClass child exists, {@code false} if it does not. 214 * @apilevel high-level 215 */ 216 public boolean hasSuperClass() { 217 return getSuperClassOpt().getNumChild() != 0; 218 } 219 /** 220 * Retrieves the (optional) SuperClass child. 221 * @return The SuperClass child, if it exists. Returns {@code null} otherwise. 222 * @apilevel low-level 223 */ 224 public Access getSuperClass() { 225 return (Access) getSuperClassOpt().getChild(0); 226 } 227 /** 228 * Retrieves the optional node for the SuperClass child. This is the <code>Opt</code> node containing the child SuperClass, not the actual child! 229 * @return The optional node for child the SuperClass child. 230 * @apilevel low-level 231 */ 232 @ASTNodeAnnotation.OptChild(name="SuperClass") 233 public Opt<Access> getSuperClassOpt() { 234 return (Opt<Access>) getChild(1); 235 } 236 /** 237 * Retrieves the optional node for child SuperClass. This is the <code>Opt</code> node containing the child SuperClass, not the actual child! 238 * <p><em>This method does not invoke AST transformations.</em></p> 239 * @return The optional node for child SuperClass. 240 * @apilevel low-level 241 */ 242 public Opt<Access> getSuperClassOptNoTransform() { 243 return (Opt<Access>) getChildNoTransform(1); 244 } 245 /** 246 * Replaces the BodyDecl list. 247 * @param list The new list node to be used as the BodyDecl list. 248 * @apilevel high-level 249 */ 250 public void setBodyDeclList(List<BodyDecl> list) { 251 setChild(list, 2); 252 } 253 /** 254 * Retrieves the number of children in the BodyDecl list. 255 * @return Number of children in the BodyDecl list. 256 * @apilevel high-level 257 */ 258 public int getNumBodyDecl() { 259 return getBodyDeclList().getNumChild(); 260 } 261 /** 262 * Retrieves the number of children in the BodyDecl list. 263 * Calling this method will not trigger rewrites. 264 * @return Number of children in the BodyDecl list. 265 * @apilevel low-level 266 */ 267 public int getNumBodyDeclNoTransform() { 268 return getBodyDeclListNoTransform().getNumChildNoTransform(); 269 } 270 /** 271 * Retrieves the element at index {@code i} in the BodyDecl list. 272 * @param i Index of the element to return. 273 * @return The element at position {@code i} in the BodyDecl list. 274 * @apilevel high-level 275 */ 276 public BodyDecl getBodyDecl(int i) { 277 return (BodyDecl) getBodyDeclList().getChild(i); 278 } 279 /** 280 * Check whether the BodyDecl list has any children. 281 * @return {@code true} if it has at least one child, {@code false} otherwise. 282 * @apilevel high-level 283 */ 284 public boolean hasBodyDecl() { 285 return getBodyDeclList().getNumChild() != 0; 286 } 287 /** 288 * Append an element to the BodyDecl list. 289 * @param node The element to append to the BodyDecl list. 290 * @apilevel high-level 291 */ 292 public void addBodyDecl(BodyDecl node) { 293 List<BodyDecl> list = (parent == null) ? getBodyDeclListNoTransform() : getBodyDeclList(); 294 list.addChild(node); 295 } 296 /** 297 * @apilevel low-level 298 */ 299 public void addBodyDeclNoTransform(BodyDecl node) { 300 List<BodyDecl> list = getBodyDeclListNoTransform(); 301 list.addChild(node); 302 } 303 /** 304 * Replaces the BodyDecl list element at index {@code i} with the new node {@code node}. 305 * @param node The new node to replace the old list element. 306 * @param i The list index of the node to be replaced. 307 * @apilevel high-level 308 */ 309 public void setBodyDecl(BodyDecl node, int i) { 310 List<BodyDecl> list = getBodyDeclList(); 311 list.setChild(node, i); 312 } 313 /** 314 * Retrieves the BodyDecl list. 315 * @return The node representing the BodyDecl list. 316 * @apilevel high-level 317 */ 318 @ASTNodeAnnotation.ListChild(name="BodyDecl") 319 public List<BodyDecl> getBodyDeclList() { 320 List<BodyDecl> list = (List<BodyDecl>) getChild(2); 321 return list; 322 } 323 /** 324 * Retrieves the BodyDecl list. 325 * <p><em>This method does not invoke AST transformations.</em></p> 326 * @return The node representing the BodyDecl list. 327 * @apilevel low-level 328 */ 329 public List<BodyDecl> getBodyDeclListNoTransform() { 330 return (List<BodyDecl>) getChildNoTransform(2); 331 } 332 /** 333 * Retrieves the BodyDecl list. 334 * @return The node representing the BodyDecl list. 335 * @apilevel high-level 336 */ 337 public List<BodyDecl> getBodyDecls() { 338 return getBodyDeclList(); 339 } 340 /** 341 * Retrieves the BodyDecl list. 342 * <p><em>This method does not invoke AST transformations.</em></p> 343 * @return The node representing the BodyDecl list. 344 * @apilevel low-level 345 */ 346 public List<BodyDecl> getBodyDeclsNoTransform() { 347 return getBodyDeclListNoTransform(); 348 } 349 /** 350 * @aspect NumericPromotion 351 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:176 352 */ 353 private TypeDecl refined_NumericPromotion_NumericType_binaryNumericPromotion_TypeDecl(TypeDecl type) 354 { 355 if (!type.isNumericType()) { 356 return unknownType(); 357 } 358 return unaryNumericPromotion().instanceOf(type) ? type : unaryNumericPromotion(); 359 } 360 /** 361 * @apilevel internal 362 */ 363 protected boolean unaryNumericPromotion_computed = false; 364 /** 365 * @apilevel internal 366 */ 367 protected TypeDecl unaryNumericPromotion_value; 368 /** 369 * @apilevel internal 370 */ 371 private void unaryNumericPromotion_reset() { 372 unaryNumericPromotion_computed = false; 373 unaryNumericPromotion_value = null; 374 } 375 /** 376 * @attribute syn 377 * @aspect NumericPromotion 378 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:169 379 */ 380 @ASTNodeAnnotation.Attribute 381 public TypeDecl unaryNumericPromotion() { 382 ASTNode$State state = state(); 383 if (unaryNumericPromotion_computed) { 384 return unaryNumericPromotion_value; 385 } 386 boolean intermediate = state.INTERMEDIATE_VALUE; 387 state.INTERMEDIATE_VALUE = false; 388 int num = state.boundariesCrossed; 389 boolean isFinal = this.is$Final(); 390 unaryNumericPromotion_value = this; 391 if (isFinal && num == state().boundariesCrossed) { 392 unaryNumericPromotion_computed = true; 393 } else { 394 } 395 state.INTERMEDIATE_VALUE |= intermediate; 396 397 return unaryNumericPromotion_value; 398 } 399 /** 400 * @apilevel internal 401 */ 402 protected java.util.Map binaryNumericPromotion_TypeDecl_values; 403 /** 404 * @apilevel internal 405 */ 406 private void binaryNumericPromotion_TypeDecl_reset() { 407 binaryNumericPromotion_TypeDecl_values = null; 408 } 409 /** 410 * @attribute syn 411 * @aspect NumericPromotion 412 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:176 413 */ 414 @ASTNodeAnnotation.Attribute 415 public TypeDecl binaryNumericPromotion(TypeDecl type) { 416 Object _parameters = type; 417 if (binaryNumericPromotion_TypeDecl_values == null) binaryNumericPromotion_TypeDecl_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 418 ASTNode$State state = state(); 419 if (binaryNumericPromotion_TypeDecl_values.containsKey(_parameters)) { 420 return (TypeDecl) binaryNumericPromotion_TypeDecl_values.get(_parameters); 421 } 422 boolean intermediate = state.INTERMEDIATE_VALUE; 423 state.INTERMEDIATE_VALUE = false; 424 int num = state.boundariesCrossed; 425 boolean isFinal = this.is$Final(); 426 TypeDecl binaryNumericPromotion_TypeDecl_value = binaryNumericPromotion_compute(type); 427 if (isFinal && num == state().boundariesCrossed) { 428 binaryNumericPromotion_TypeDecl_values.put(_parameters, binaryNumericPromotion_TypeDecl_value); 429 } else { 430 } 431 state.INTERMEDIATE_VALUE |= intermediate; 432 433 return binaryNumericPromotion_TypeDecl_value; 434 } 435 /** 436 * @apilevel internal 437 */ 438 private TypeDecl binaryNumericPromotion_compute(TypeDecl type) { 439 if (type.isReferenceType()) { 440 return refined_NumericPromotion_NumericType_binaryNumericPromotion_TypeDecl(type.unboxed()); 441 } else { 442 return refined_NumericPromotion_NumericType_binaryNumericPromotion_TypeDecl(type); 443 } 444 } 445 /** 446 * @attribute syn 447 * @aspect TypeAnalysis 448 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:195 449 */ 450 @ASTNodeAnnotation.Attribute 451 public boolean isNumericType() { 452 boolean isNumericType_value = true; 453 454 return isNumericType_value; 455 } 456 /** 457 * @apilevel internal 458 */ 459 public ASTNode rewriteTo() { 460 return super.rewriteTo(); 461 } 462 }