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