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:55 027 * @production IntType : {@link IntegralType}; 028 029 */ 030 public class IntType extends IntegralType implements Cloneable { 031 /** 032 * @aspect Java4PrettyPrint 033 * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrint.jadd:133 034 */ 035 public void prettyPrint(PrettyPrinter out) { 036 out.print("int"); 037 } 038 /** 039 * @aspect CodeGenerationConversions 040 * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:581 041 */ 042 void emitCastTo(CodeGeneration gen, TypeDecl type) { type.intToThis(gen); } 043 /** 044 * @aspect CodeGenerationConversions 045 * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:592 046 */ 047 void intToThis(CodeGeneration gen) { } 048 /** 049 * @aspect CodeGenerationConversions 050 * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:601 051 */ 052 void floatToThis(CodeGeneration gen) { gen.emit(Bytecode.F2I); } 053 /** 054 * @aspect CodeGenerationConversions 055 * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:610 056 */ 057 void doubleToThis(CodeGeneration gen) { gen.emit(Bytecode.D2I); } 058 /** 059 * @aspect CodeGenerationConversions 060 * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:619 061 */ 062 void longToThis(CodeGeneration gen) { gen.emit(Bytecode.L2I); } 063 /** 064 * @declaredat ASTNode:1 065 */ 066 public IntType() { 067 super(); 068 } 069 /** 070 * Initializes the child array to the correct size. 071 * Initializes List and Opt nta children. 072 * @apilevel internal 073 * @ast method 074 * @declaredat ASTNode:10 075 */ 076 public void init$Children() { 077 children = new ASTNode[3]; 078 setChild(new Opt(), 1); 079 setChild(new List(), 2); 080 } 081 /** 082 * @declaredat ASTNode:15 083 */ 084 public IntType(Modifiers p0, String p1, Opt<Access> p2, List<BodyDecl> p3) { 085 setChild(p0, 0); 086 setID(p1); 087 setChild(p2, 1); 088 setChild(p3, 2); 089 } 090 /** 091 * @declaredat ASTNode:21 092 */ 093 public IntType(Modifiers p0, beaver.Symbol p1, Opt<Access> p2, List<BodyDecl> p3) { 094 setChild(p0, 0); 095 setID(p1); 096 setChild(p2, 1); 097 setChild(p3, 2); 098 } 099 /** 100 * @apilevel low-level 101 * @declaredat ASTNode:30 102 */ 103 protected int numChildren() { 104 return 3; 105 } 106 /** 107 * @apilevel internal 108 * @declaredat ASTNode:36 109 */ 110 public boolean mayHaveRewrite() { 111 return false; 112 } 113 /** 114 * @apilevel internal 115 * @declaredat ASTNode:42 116 */ 117 public void flushAttrCache() { 118 super.flushAttrCache(); 119 typeDescriptor_reset(); 120 jvmName_reset(); 121 boxed_reset(); 122 } 123 /** 124 * @apilevel internal 125 * @declaredat ASTNode:51 126 */ 127 public void flushCollectionCache() { 128 super.flushCollectionCache(); 129 } 130 /** 131 * @apilevel internal 132 * @declaredat ASTNode:57 133 */ 134 public void flushRewriteCache() { 135 super.flushRewriteCache(); 136 } 137 /** 138 * @apilevel internal 139 * @declaredat ASTNode:63 140 */ 141 public IntType clone() throws CloneNotSupportedException { 142 IntType node = (IntType) super.clone(); 143 return node; 144 } 145 /** 146 * @apilevel internal 147 * @declaredat ASTNode:70 148 */ 149 public IntType copy() { 150 try { 151 IntType node = (IntType) clone(); 152 node.parent = null; 153 if (children != null) { 154 node.children = (ASTNode[]) children.clone(); 155 } 156 return node; 157 } catch (CloneNotSupportedException e) { 158 throw new Error("Error: clone not supported for " + getClass().getName()); 159 } 160 } 161 /** 162 * Create a deep copy of the AST subtree at this node. 163 * The copy is dangling, i.e. has no parent. 164 * @return dangling copy of the subtree at this node 165 * @apilevel low-level 166 * @deprecated Please use treeCopy or treeCopyNoTransform instead 167 * @declaredat ASTNode:89 168 */ 169 @Deprecated 170 public IntType fullCopy() { 171 return treeCopyNoTransform(); 172 } 173 /** 174 * Create a deep copy of the AST subtree at this node. 175 * The copy is dangling, i.e. has no parent. 176 * @return dangling copy of the subtree at this node 177 * @apilevel low-level 178 * @declaredat ASTNode:99 179 */ 180 public IntType treeCopyNoTransform() { 181 IntType tree = (IntType) copy(); 182 if (children != null) { 183 for (int i = 0; i < children.length; ++i) { 184 ASTNode child = (ASTNode) children[i]; 185 if (child != null) { 186 child = child.treeCopyNoTransform(); 187 tree.setChild(child, i); 188 } 189 } 190 } 191 return tree; 192 } 193 /** 194 * Create a deep copy of the AST subtree at this node. 195 * The subtree of this node is traversed to trigger rewrites before copy. 196 * The copy is dangling, i.e. has no parent. 197 * @return dangling copy of the subtree at this node 198 * @apilevel low-level 199 * @declaredat ASTNode:119 200 */ 201 public IntType treeCopy() { 202 doFullTraversal(); 203 return treeCopyNoTransform(); 204 } 205 /** 206 * @apilevel internal 207 * @declaredat ASTNode:126 208 */ 209 protected boolean is$Equal(ASTNode node) { 210 return super.is$Equal(node) && (tokenString_ID == ((IntType)node).tokenString_ID); 211 } 212 /** 213 * Replaces the Modifiers child. 214 * @param node The new node to replace the Modifiers child. 215 * @apilevel high-level 216 */ 217 public void setModifiers(Modifiers node) { 218 setChild(node, 0); 219 } 220 /** 221 * Retrieves the Modifiers child. 222 * @return The current node used as the Modifiers child. 223 * @apilevel high-level 224 */ 225 @ASTNodeAnnotation.Child(name="Modifiers") 226 public Modifiers getModifiers() { 227 return (Modifiers) getChild(0); 228 } 229 /** 230 * Retrieves the Modifiers child. 231 * <p><em>This method does not invoke AST transformations.</em></p> 232 * @return The current node used as the Modifiers child. 233 * @apilevel low-level 234 */ 235 public Modifiers getModifiersNoTransform() { 236 return (Modifiers) getChildNoTransform(0); 237 } 238 /** 239 * Replaces the lexeme ID. 240 * @param value The new value for the lexeme ID. 241 * @apilevel high-level 242 */ 243 public void setID(String value) { 244 tokenString_ID = value; 245 } 246 /** 247 * JastAdd-internal setter for lexeme ID using the Beaver parser. 248 * @param symbol Symbol containing the new value for the lexeme ID 249 * @apilevel internal 250 */ 251 public void setID(beaver.Symbol symbol) { 252 if (symbol.value != null && !(symbol.value instanceof String)) 253 throw new UnsupportedOperationException("setID is only valid for String lexemes"); 254 tokenString_ID = (String)symbol.value; 255 IDstart = symbol.getStart(); 256 IDend = symbol.getEnd(); 257 } 258 /** 259 * Retrieves the value for the lexeme ID. 260 * @return The value for the lexeme ID. 261 * @apilevel high-level 262 */ 263 @ASTNodeAnnotation.Token(name="ID") 264 public String getID() { 265 return tokenString_ID != null ? tokenString_ID : ""; 266 } 267 /** 268 * Replaces the optional node for the SuperClass child. This is the <code>Opt</code> 269 * node containing the child SuperClass, not the actual child! 270 * @param opt The new node to be used as the optional node for the SuperClass child. 271 * @apilevel low-level 272 */ 273 public void setSuperClassOpt(Opt<Access> opt) { 274 setChild(opt, 1); 275 } 276 /** 277 * Replaces the (optional) SuperClass child. 278 * @param node The new node to be used as the SuperClass child. 279 * @apilevel high-level 280 */ 281 public void setSuperClass(Access node) { 282 getSuperClassOpt().setChild(node, 0); 283 } 284 /** 285 * Check whether the optional SuperClass child exists. 286 * @return {@code true} if the optional SuperClass child exists, {@code false} if it does not. 287 * @apilevel high-level 288 */ 289 public boolean hasSuperClass() { 290 return getSuperClassOpt().getNumChild() != 0; 291 } 292 /** 293 * Retrieves the (optional) SuperClass child. 294 * @return The SuperClass child, if it exists. Returns {@code null} otherwise. 295 * @apilevel low-level 296 */ 297 public Access getSuperClass() { 298 return (Access) getSuperClassOpt().getChild(0); 299 } 300 /** 301 * Retrieves the optional node for the SuperClass child. This is the <code>Opt</code> node containing the child SuperClass, not the actual child! 302 * @return The optional node for child the SuperClass child. 303 * @apilevel low-level 304 */ 305 @ASTNodeAnnotation.OptChild(name="SuperClass") 306 public Opt<Access> getSuperClassOpt() { 307 return (Opt<Access>) getChild(1); 308 } 309 /** 310 * Retrieves the optional node for child SuperClass. This is the <code>Opt</code> node containing the child SuperClass, not the actual child! 311 * <p><em>This method does not invoke AST transformations.</em></p> 312 * @return The optional node for child SuperClass. 313 * @apilevel low-level 314 */ 315 public Opt<Access> getSuperClassOptNoTransform() { 316 return (Opt<Access>) getChildNoTransform(1); 317 } 318 /** 319 * Replaces the BodyDecl list. 320 * @param list The new list node to be used as the BodyDecl list. 321 * @apilevel high-level 322 */ 323 public void setBodyDeclList(List<BodyDecl> list) { 324 setChild(list, 2); 325 } 326 /** 327 * Retrieves the number of children in the BodyDecl list. 328 * @return Number of children in the BodyDecl list. 329 * @apilevel high-level 330 */ 331 public int getNumBodyDecl() { 332 return getBodyDeclList().getNumChild(); 333 } 334 /** 335 * Retrieves the number of children in the BodyDecl list. 336 * Calling this method will not trigger rewrites. 337 * @return Number of children in the BodyDecl list. 338 * @apilevel low-level 339 */ 340 public int getNumBodyDeclNoTransform() { 341 return getBodyDeclListNoTransform().getNumChildNoTransform(); 342 } 343 /** 344 * Retrieves the element at index {@code i} in the BodyDecl list. 345 * @param i Index of the element to return. 346 * @return The element at position {@code i} in the BodyDecl list. 347 * @apilevel high-level 348 */ 349 public BodyDecl getBodyDecl(int i) { 350 return (BodyDecl) getBodyDeclList().getChild(i); 351 } 352 /** 353 * Check whether the BodyDecl list has any children. 354 * @return {@code true} if it has at least one child, {@code false} otherwise. 355 * @apilevel high-level 356 */ 357 public boolean hasBodyDecl() { 358 return getBodyDeclList().getNumChild() != 0; 359 } 360 /** 361 * Append an element to the BodyDecl list. 362 * @param node The element to append to the BodyDecl list. 363 * @apilevel high-level 364 */ 365 public void addBodyDecl(BodyDecl node) { 366 List<BodyDecl> list = (parent == null) ? getBodyDeclListNoTransform() : getBodyDeclList(); 367 list.addChild(node); 368 } 369 /** 370 * @apilevel low-level 371 */ 372 public void addBodyDeclNoTransform(BodyDecl node) { 373 List<BodyDecl> list = getBodyDeclListNoTransform(); 374 list.addChild(node); 375 } 376 /** 377 * Replaces the BodyDecl list element at index {@code i} with the new node {@code node}. 378 * @param node The new node to replace the old list element. 379 * @param i The list index of the node to be replaced. 380 * @apilevel high-level 381 */ 382 public void setBodyDecl(BodyDecl node, int i) { 383 List<BodyDecl> list = getBodyDeclList(); 384 list.setChild(node, i); 385 } 386 /** 387 * Retrieves the BodyDecl list. 388 * @return The node representing the BodyDecl list. 389 * @apilevel high-level 390 */ 391 @ASTNodeAnnotation.ListChild(name="BodyDecl") 392 public List<BodyDecl> getBodyDeclList() { 393 List<BodyDecl> list = (List<BodyDecl>) getChild(2); 394 return list; 395 } 396 /** 397 * Retrieves the BodyDecl list. 398 * <p><em>This method does not invoke AST transformations.</em></p> 399 * @return The node representing the BodyDecl list. 400 * @apilevel low-level 401 */ 402 public List<BodyDecl> getBodyDeclListNoTransform() { 403 return (List<BodyDecl>) getChildNoTransform(2); 404 } 405 /** 406 * Retrieves the BodyDecl list. 407 * @return The node representing the BodyDecl list. 408 * @apilevel high-level 409 */ 410 public List<BodyDecl> getBodyDecls() { 411 return getBodyDeclList(); 412 } 413 /** 414 * Retrieves the BodyDecl list. 415 * <p><em>This method does not invoke AST transformations.</em></p> 416 * @return The node representing the BodyDecl list. 417 * @apilevel low-level 418 */ 419 public List<BodyDecl> getBodyDeclsNoTransform() { 420 return getBodyDeclListNoTransform(); 421 } 422 /** 423 * @attribute syn 424 * @aspect TypeAnalysis 425 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:213 426 */ 427 @ASTNodeAnnotation.Attribute 428 public boolean isInt() { 429 boolean isInt_value = true; 430 431 return isInt_value; 432 } 433 /** 434 * @attribute syn 435 * @aspect CodeGeneration 436 * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:249 437 */ 438 @ASTNodeAnnotation.Attribute 439 public byte arrayLoad() { 440 byte arrayLoad_value = Bytecode.IALOAD; 441 442 return arrayLoad_value; 443 } 444 /** 445 * @attribute syn 446 * @aspect CodeGeneration 447 * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:380 448 */ 449 @ASTNodeAnnotation.Attribute 450 public byte arrayStore() { 451 byte arrayStore_value = Bytecode.IASTORE; 452 453 return arrayStore_value; 454 } 455 /** 456 * @apilevel internal 457 */ 458 protected boolean typeDescriptor_computed = false; 459 /** 460 * @apilevel internal 461 */ 462 protected String typeDescriptor_value; 463 /** 464 * @apilevel internal 465 */ 466 private void typeDescriptor_reset() { 467 typeDescriptor_computed = false; 468 typeDescriptor_value = null; 469 } 470 /** 471 * @attribute syn 472 * @aspect ConstantPoolNames 473 * @declaredat /home/jesper/git/extendj/java4/backend/ConstantPoolNames.jrag:77 474 */ 475 @ASTNodeAnnotation.Attribute 476 public String typeDescriptor() { 477 ASTNode$State state = state(); 478 if (typeDescriptor_computed) { 479 return typeDescriptor_value; 480 } 481 boolean intermediate = state.INTERMEDIATE_VALUE; 482 state.INTERMEDIATE_VALUE = false; 483 int num = state.boundariesCrossed; 484 boolean isFinal = this.is$Final(); 485 typeDescriptor_value = "I"; 486 if (isFinal && num == state().boundariesCrossed) { 487 typeDescriptor_computed = true; 488 } else { 489 } 490 state.INTERMEDIATE_VALUE |= intermediate; 491 492 return typeDescriptor_value; 493 } 494 /** 495 * @attribute syn 496 * @aspect CreateBCode 497 * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:905 498 */ 499 @ASTNodeAnnotation.Attribute 500 public int arrayPrimitiveTypeDescriptor() { 501 int arrayPrimitiveTypeDescriptor_value = 10; 502 503 return arrayPrimitiveTypeDescriptor_value; 504 } 505 /** 506 * @apilevel internal 507 */ 508 protected boolean jvmName_computed = false; 509 /** 510 * @apilevel internal 511 */ 512 protected String jvmName_value; 513 /** 514 * @apilevel internal 515 */ 516 private void jvmName_reset() { 517 jvmName_computed = false; 518 jvmName_value = null; 519 } 520 /** 521 * @attribute syn 522 * @aspect Java2Rewrites 523 * @declaredat /home/jesper/git/extendj/java4/backend/Java2Rewrites.jrag:36 524 */ 525 @ASTNodeAnnotation.Attribute 526 public String jvmName() { 527 ASTNode$State state = state(); 528 if (jvmName_computed) { 529 return jvmName_value; 530 } 531 boolean intermediate = state.INTERMEDIATE_VALUE; 532 state.INTERMEDIATE_VALUE = false; 533 int num = state.boundariesCrossed; 534 boolean isFinal = this.is$Final(); 535 jvmName_value = "I"; 536 if (isFinal && num == state().boundariesCrossed) { 537 jvmName_computed = true; 538 } else { 539 } 540 state.INTERMEDIATE_VALUE |= intermediate; 541 542 return jvmName_value; 543 } 544 /** 545 * @attribute syn 546 * @aspect Java2Rewrites 547 * @declaredat /home/jesper/git/extendj/java4/backend/Java2Rewrites.jrag:68 548 */ 549 @ASTNodeAnnotation.Attribute 550 public String primitiveClassName() { 551 String primitiveClassName_value = "Integer"; 552 553 return primitiveClassName_value; 554 } 555 /** 556 * @apilevel internal 557 */ 558 protected boolean boxed_computed = false; 559 /** 560 * @apilevel internal 561 */ 562 protected TypeDecl boxed_value; 563 /** 564 * @apilevel internal 565 */ 566 private void boxed_reset() { 567 boxed_computed = false; 568 boxed_value = null; 569 } 570 /** 571 * @attribute syn 572 * @aspect AutoBoxing 573 * @declaredat /home/jesper/git/extendj/java5/frontend/AutoBoxing.jrag:56 574 */ 575 @ASTNodeAnnotation.Attribute 576 public TypeDecl boxed() { 577 ASTNode$State state = state(); 578 if (boxed_computed) { 579 return boxed_value; 580 } 581 boolean intermediate = state.INTERMEDIATE_VALUE; 582 state.INTERMEDIATE_VALUE = false; 583 int num = state.boundariesCrossed; 584 boolean isFinal = this.is$Final(); 585 boxed_value = lookupType("java.lang", "Integer"); 586 if (isFinal && num == state().boundariesCrossed) { 587 boxed_computed = true; 588 } else { 589 } 590 state.INTERMEDIATE_VALUE |= intermediate; 591 592 return boxed_value; 593 } 594 /** 595 * @apilevel internal 596 */ 597 public ASTNode rewriteTo() { 598 return super.rewriteTo(); 599 } 600 }