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 /** 015 * @production GenericInterfaceDecl : {@link InterfaceDecl} ::= <span class="component">{@link Modifiers}</span> <span class="component"><ID:String></span> <span class="component">SuperInterfaceId:{@link Access}*</span> <span class="component">{@link BodyDecl}*</span> <span class="component">TypeParameter:{@link TypeVariable}*</span>; 016 * @ast node 017 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.ast:3 018 */ 019 public class GenericInterfaceDecl extends InterfaceDecl implements Cloneable, GenericTypeDecl { 020 /** 021 * @apilevel low-level 022 */ 023 public void flushCache() { 024 } 025 /** 026 * @apilevel internal 027 */ 028 public void flushCollectionCache() { 029 } 030 /** 031 * @apilevel internal 032 */ 033 @SuppressWarnings({"unchecked", "cast"}) 034 public GenericInterfaceDecl clone() throws CloneNotSupportedException { 035 GenericInterfaceDecl node = (GenericInterfaceDecl)super.clone(); 036 node.rawType_computed = false; 037 node.rawType_value = null; 038 node.lookupParTypeDecl_ArrayList_values = null; 039 node.lookupParTypeDecl_ArrayList_list = null; node.usesTypeVariable_visited = -1; 040 node.usesTypeVariable_computed = false; 041 node.usesTypeVariable_initialized = false; 042 node.subtype_TypeDecl_values = null; 043 node.instanceOf_TypeDecl_values = null; 044 node.constantPoolName_computed = false; 045 node.constantPoolName_value = null; 046 node.needsSignatureAttribute_computed = false; 047 node.classSignature_computed = false; 048 node.classSignature_value = null; 049 node.lookupParTypeDecl_ParTypeAccess_values = null; 050 node.in$Circle(false); 051 node.is$Final(false); 052 return node; 053 } 054 /** 055 * @apilevel internal 056 */ 057 @SuppressWarnings({"unchecked", "cast"}) 058 public GenericInterfaceDecl copy() { 059 060 try { 061 GenericInterfaceDecl node = (GenericInterfaceDecl) clone(); 062 node.parent = null; 063 if(children != null) 064 node.children = (ASTNode[]) children.clone(); 065 066 return node; 067 } catch (CloneNotSupportedException e) { 068 throw new Error("Error: clone not supported for " + getClass().getName()); 069 } 070 071 }/** 072 * Create a deep copy of the AST subtree at this node. 073 * The copy is dangling, i.e. has no parent. 074 * @return dangling copy of the subtree at this node 075 * @apilevel low-level 076 */ 077 @SuppressWarnings({"unchecked", "cast"}) 078 public GenericInterfaceDecl fullCopy() { 079 080 GenericInterfaceDecl tree = (GenericInterfaceDecl) copy(); 081 if (children != null) { 082 for (int i = 0; i < children.length; ++i) { 083 084 ASTNode child = (ASTNode) children[i]; 085 if(child != null) { 086 child = child.fullCopy(); 087 tree.setChild(child, i); 088 } 089 } 090 } 091 return tree; 092 093 } /** 094 * @ast method 095 * @aspect GenericsTypeCheck 096 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:430 097 */ 098 public void typeCheck() { 099 super.typeCheck(); 100 if(instanceOf(typeThrowable())) 101 error(" generic interface " + typeName() + " may not directly or indirectly inherit java.lang.Throwable"); 102 } 103 /** 104 * @ast method 105 * @aspect LookupParTypeDecl 106 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:1346 107 */ 108 public InterfaceDecl substitutedInterfaceDecl(Parameterization parTypeDecl) { 109 GenericInterfaceDecl c = new GenericInterfaceDeclSubstituted( 110 (Modifiers)getModifiers().fullCopy(), 111 getID(), 112 getSuperInterfaceIdList().substitute(parTypeDecl), 113 // ES: new List(), 114 new List(), // delegates TypeParameter lookup to original 115 this 116 ); 117 return c; 118 } 119 /** 120 * @ast method 121 * @aspect GenericsPrettyPrint 122 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsPrettyPrint.jrag:115 123 */ 124 public void toString(StringBuffer s) { 125 getModifiers().toString(s); 126 s.append("interface " + getID()); 127 s.append('<'); 128 if (getNumTypeParameter() > 0) { 129 getTypeParameter(0).toString(s); 130 for (int i = 1; i < getNumTypeParameter(); i++) { 131 s.append(", "); 132 getTypeParameter(i).toString(s); 133 } 134 } 135 s.append('>'); 136 if(getNumSuperInterfaceId() > 0) { 137 s.append(" extends "); 138 getSuperInterfaceId(0).toString(s); 139 for(int i = 1; i < getNumSuperInterfaceId(); i++) { 140 s.append(", "); 141 getSuperInterfaceId(i).toString(s); 142 } 143 } 144 145 /* 146 147 s.append(" instantiated with: "); 148 for(int i = 0; i < getNumParTypeDecl(); i++) { 149 if(i != 0) s.append(", "); 150 ParTypeDecl decl = getParTypeDecl(i); 151 s.append("<"); 152 for(int j = 0; j < decl.getNumArgument(); j++) { 153 if(j != 0) s.append(", "); 154 s.append(decl.getArgument(j).type().fullName()); 155 } 156 s.append(">"); 157 } 158 */ 159 160 ppBodyDecls(s); 161 162 /* 163 for(int i = 0; i < getNumParTypeDecl(); i++) { 164 ParInterfaceDecl decl = getParTypeDecl(i); 165 decl.toString(s); 166 } 167 */ 168 } 169 /** 170 * @ast method 171 * @aspect Generics 172 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:235 173 */ 174 public TypeDecl makeGeneric(Signatures.ClassSignature s) { 175 return (TypeDecl)this; 176 } 177 /** 178 * @ast method 179 * @aspect GenericsNameBinding 180 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:489 181 */ 182 public SimpleSet addTypeVariables(SimpleSet c, String name) { 183 GenericTypeDecl original = (GenericTypeDecl)original(); 184 for(int i = 0; i < original.getNumTypeParameter(); i++) { 185 TypeVariable p = original.getTypeParameter(i); 186 if(p.name().equals(name)) 187 c = c.add(p); 188 } 189 return c; 190 } 191 /** 192 * @ast method 193 * @aspect LookupParTypeDecl 194 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:799 195 */ 196 public List createArgumentList(ArrayList params) { 197 GenericTypeDecl original = (GenericTypeDecl)original(); 198 List list = new List(); 199 if(params.isEmpty()) { 200 // Change: Don't add any thing to the list. 201 // Concern: The previous version seem to add the erasure of the type variable for some reason, 202 // maybe this is how the raw type is represented (?), but this doesn't really comply with the 203 // claim that raw types don't have any type variables...? 204 for(int i = 0; i < original.getNumTypeParameter(); i++) 205 list.add(original.getTypeParameter(i).erasure().createBoundAccess()); 206 } else 207 for(Iterator iter = params.iterator(); iter.hasNext(); ) 208 list.add(((TypeDecl)iter.next()).createBoundAccess()); 209 return list; 210 } 211 /** 212 * @ast method 213 * 214 */ 215 public GenericInterfaceDecl() { 216 super(); 217 218 219 } 220 /** 221 * Initializes the child array to the correct size. 222 * Initializes List and Opt nta children. 223 * @apilevel internal 224 * @ast method 225 * @ast method 226 * 227 */ 228 public void init$Children() { 229 children = new ASTNode[4]; 230 setChild(new List(), 1); 231 setChild(new List(), 2); 232 setChild(new List(), 3); 233 } 234 /** 235 * @ast method 236 * 237 */ 238 public GenericInterfaceDecl(Modifiers p0, String p1, List<Access> p2, List<BodyDecl> p3, List<TypeVariable> p4) { 239 setChild(p0, 0); 240 setID(p1); 241 setChild(p2, 1); 242 setChild(p3, 2); 243 setChild(p4, 3); 244 } 245 /** 246 * @ast method 247 * 248 */ 249 public GenericInterfaceDecl(Modifiers p0, beaver.Symbol p1, List<Access> p2, List<BodyDecl> p3, List<TypeVariable> p4) { 250 setChild(p0, 0); 251 setID(p1); 252 setChild(p2, 1); 253 setChild(p3, 2); 254 setChild(p4, 3); 255 } 256 /** 257 * @apilevel low-level 258 * @ast method 259 * 260 */ 261 protected int numChildren() { 262 return 4; 263 } 264 /** 265 * @apilevel internal 266 * @ast method 267 * 268 */ 269 public boolean mayHaveRewrite() { 270 return false; 271 } 272 /** 273 * Replaces the Modifiers child. 274 * @param node The new node to replace the Modifiers child. 275 * @apilevel high-level 276 * @ast method 277 * 278 */ 279 public void setModifiers(Modifiers node) { 280 setChild(node, 0); 281 } 282 /** 283 * Retrieves the Modifiers child. 284 * @return The current node used as the Modifiers child. 285 * @apilevel high-level 286 * @ast method 287 * 288 */ 289 public Modifiers getModifiers() { 290 return (Modifiers)getChild(0); 291 } 292 /** 293 * Retrieves the Modifiers child. 294 * <p><em>This method does not invoke AST transformations.</em></p> 295 * @return The current node used as the Modifiers child. 296 * @apilevel low-level 297 * @ast method 298 * 299 */ 300 public Modifiers getModifiersNoTransform() { 301 return (Modifiers)getChildNoTransform(0); 302 } 303 /** 304 * Replaces the lexeme ID. 305 * @param value The new value for the lexeme ID. 306 * @apilevel high-level 307 * @ast method 308 * 309 */ 310 public void setID(String value) { 311 tokenString_ID = value; 312 } 313 /** 314 * JastAdd-internal setter for lexeme ID using the Beaver parser. 315 * @apilevel internal 316 * @ast method 317 * 318 */ 319 public void setID(beaver.Symbol symbol) { 320 if(symbol.value != null && !(symbol.value instanceof String)) 321 throw new UnsupportedOperationException("setID is only valid for String lexemes"); 322 tokenString_ID = (String)symbol.value; 323 IDstart = symbol.getStart(); 324 IDend = symbol.getEnd(); 325 } 326 /** 327 * Retrieves the value for the lexeme ID. 328 * @return The value for the lexeme ID. 329 * @apilevel high-level 330 * @ast method 331 * 332 */ 333 public String getID() { 334 return tokenString_ID != null ? tokenString_ID : ""; 335 } 336 /** 337 * Replaces the SuperInterfaceId list. 338 * @param list The new list node to be used as the SuperInterfaceId list. 339 * @apilevel high-level 340 * @ast method 341 * 342 */ 343 public void setSuperInterfaceIdList(List<Access> list) { 344 setChild(list, 1); 345 } 346 /** 347 * Retrieves the number of children in the SuperInterfaceId list. 348 * @return Number of children in the SuperInterfaceId list. 349 * @apilevel high-level 350 * @ast method 351 * 352 */ 353 public int getNumSuperInterfaceId() { 354 return getSuperInterfaceIdList().getNumChild(); 355 } 356 /** 357 * Retrieves the number of children in the SuperInterfaceId list. 358 * Calling this method will not trigger rewrites.. 359 * @return Number of children in the SuperInterfaceId list. 360 * @apilevel low-level 361 * @ast method 362 * 363 */ 364 public int getNumSuperInterfaceIdNoTransform() { 365 return getSuperInterfaceIdListNoTransform().getNumChildNoTransform(); 366 } 367 /** 368 * Retrieves the element at index {@code i} in the SuperInterfaceId list.. 369 * @param i Index of the element to return. 370 * @return The element at position {@code i} in the SuperInterfaceId list. 371 * @apilevel high-level 372 * @ast method 373 * 374 */ 375 @SuppressWarnings({"unchecked", "cast"}) 376 public Access getSuperInterfaceId(int i) { 377 return (Access)getSuperInterfaceIdList().getChild(i); 378 } 379 /** 380 * Append an element to the SuperInterfaceId list. 381 * @param node The element to append to the SuperInterfaceId list. 382 * @apilevel high-level 383 * @ast method 384 * 385 */ 386 public void addSuperInterfaceId(Access node) { 387 List<Access> list = (parent == null || state == null) ? getSuperInterfaceIdListNoTransform() : getSuperInterfaceIdList(); 388 list.addChild(node); 389 } 390 /** 391 * @apilevel low-level 392 * @ast method 393 * 394 */ 395 public void addSuperInterfaceIdNoTransform(Access node) { 396 List<Access> list = getSuperInterfaceIdListNoTransform(); 397 list.addChild(node); 398 } 399 /** 400 * Replaces the SuperInterfaceId list element at index {@code i} with the new node {@code node}. 401 * @param node The new node to replace the old list element. 402 * @param i The list index of the node to be replaced. 403 * @apilevel high-level 404 * @ast method 405 * 406 */ 407 public void setSuperInterfaceId(Access node, int i) { 408 List<Access> list = getSuperInterfaceIdList(); 409 list.setChild(node, i); 410 } 411 /** 412 * Retrieves the SuperInterfaceId list. 413 * @return The node representing the SuperInterfaceId list. 414 * @apilevel high-level 415 * @ast method 416 * 417 */ 418 public List<Access> getSuperInterfaceIds() { 419 return getSuperInterfaceIdList(); 420 } 421 /** 422 * Retrieves the SuperInterfaceId list. 423 * <p><em>This method does not invoke AST transformations.</em></p> 424 * @return The node representing the SuperInterfaceId list. 425 * @apilevel low-level 426 * @ast method 427 * 428 */ 429 public List<Access> getSuperInterfaceIdsNoTransform() { 430 return getSuperInterfaceIdListNoTransform(); 431 } 432 /** 433 * Retrieves the SuperInterfaceId list. 434 * @return The node representing the SuperInterfaceId list. 435 * @apilevel high-level 436 * @ast method 437 * 438 */ 439 @SuppressWarnings({"unchecked", "cast"}) 440 public List<Access> getSuperInterfaceIdList() { 441 List<Access> list = (List<Access>)getChild(1); 442 list.getNumChild(); 443 return list; 444 } 445 /** 446 * Retrieves the SuperInterfaceId list. 447 * <p><em>This method does not invoke AST transformations.</em></p> 448 * @return The node representing the SuperInterfaceId list. 449 * @apilevel low-level 450 * @ast method 451 * 452 */ 453 @SuppressWarnings({"unchecked", "cast"}) 454 public List<Access> getSuperInterfaceIdListNoTransform() { 455 return (List<Access>)getChildNoTransform(1); 456 } 457 /** 458 * Replaces the BodyDecl list. 459 * @param list The new list node to be used as the BodyDecl list. 460 * @apilevel high-level 461 * @ast method 462 * 463 */ 464 public void setBodyDeclList(List<BodyDecl> list) { 465 setChild(list, 2); 466 } 467 /** 468 * Retrieves the number of children in the BodyDecl list. 469 * @return Number of children in the BodyDecl list. 470 * @apilevel high-level 471 * @ast method 472 * 473 */ 474 public int getNumBodyDecl() { 475 return getBodyDeclList().getNumChild(); 476 } 477 /** 478 * Retrieves the number of children in the BodyDecl list. 479 * Calling this method will not trigger rewrites.. 480 * @return Number of children in the BodyDecl list. 481 * @apilevel low-level 482 * @ast method 483 * 484 */ 485 public int getNumBodyDeclNoTransform() { 486 return getBodyDeclListNoTransform().getNumChildNoTransform(); 487 } 488 /** 489 * Retrieves the element at index {@code i} in the BodyDecl list.. 490 * @param i Index of the element to return. 491 * @return The element at position {@code i} in the BodyDecl list. 492 * @apilevel high-level 493 * @ast method 494 * 495 */ 496 @SuppressWarnings({"unchecked", "cast"}) 497 public BodyDecl getBodyDecl(int i) { 498 return (BodyDecl)getBodyDeclList().getChild(i); 499 } 500 /** 501 * Append an element to the BodyDecl list. 502 * @param node The element to append to the BodyDecl list. 503 * @apilevel high-level 504 * @ast method 505 * 506 */ 507 public void addBodyDecl(BodyDecl node) { 508 List<BodyDecl> list = (parent == null || state == null) ? getBodyDeclListNoTransform() : getBodyDeclList(); 509 list.addChild(node); 510 } 511 /** 512 * @apilevel low-level 513 * @ast method 514 * 515 */ 516 public void addBodyDeclNoTransform(BodyDecl node) { 517 List<BodyDecl> list = getBodyDeclListNoTransform(); 518 list.addChild(node); 519 } 520 /** 521 * Replaces the BodyDecl list element at index {@code i} with the new node {@code node}. 522 * @param node The new node to replace the old list element. 523 * @param i The list index of the node to be replaced. 524 * @apilevel high-level 525 * @ast method 526 * 527 */ 528 public void setBodyDecl(BodyDecl node, int i) { 529 List<BodyDecl> list = getBodyDeclList(); 530 list.setChild(node, i); 531 } 532 /** 533 * Retrieves the BodyDecl list. 534 * @return The node representing the BodyDecl list. 535 * @apilevel high-level 536 * @ast method 537 * 538 */ 539 public List<BodyDecl> getBodyDecls() { 540 return getBodyDeclList(); 541 } 542 /** 543 * Retrieves the BodyDecl list. 544 * <p><em>This method does not invoke AST transformations.</em></p> 545 * @return The node representing the BodyDecl list. 546 * @apilevel low-level 547 * @ast method 548 * 549 */ 550 public List<BodyDecl> getBodyDeclsNoTransform() { 551 return getBodyDeclListNoTransform(); 552 } 553 /** 554 * Retrieves the BodyDecl list. 555 * @return The node representing the BodyDecl list. 556 * @apilevel high-level 557 * @ast method 558 * 559 */ 560 @SuppressWarnings({"unchecked", "cast"}) 561 public List<BodyDecl> getBodyDeclList() { 562 List<BodyDecl> list = (List<BodyDecl>)getChild(2); 563 list.getNumChild(); 564 return list; 565 } 566 /** 567 * Retrieves the BodyDecl list. 568 * <p><em>This method does not invoke AST transformations.</em></p> 569 * @return The node representing the BodyDecl list. 570 * @apilevel low-level 571 * @ast method 572 * 573 */ 574 @SuppressWarnings({"unchecked", "cast"}) 575 public List<BodyDecl> getBodyDeclListNoTransform() { 576 return (List<BodyDecl>)getChildNoTransform(2); 577 } 578 /** 579 * Replaces the TypeParameter list. 580 * @param list The new list node to be used as the TypeParameter list. 581 * @apilevel high-level 582 * @ast method 583 * 584 */ 585 public void setTypeParameterList(List<TypeVariable> list) { 586 setChild(list, 3); 587 } 588 /** 589 * Retrieves the number of children in the TypeParameter list. 590 * @return Number of children in the TypeParameter list. 591 * @apilevel high-level 592 * @ast method 593 * 594 */ 595 public int getNumTypeParameter() { 596 return getTypeParameterList().getNumChild(); 597 } 598 /** 599 * Retrieves the number of children in the TypeParameter list. 600 * Calling this method will not trigger rewrites.. 601 * @return Number of children in the TypeParameter list. 602 * @apilevel low-level 603 * @ast method 604 * 605 */ 606 public int getNumTypeParameterNoTransform() { 607 return getTypeParameterListNoTransform().getNumChildNoTransform(); 608 } 609 /** 610 * Retrieves the element at index {@code i} in the TypeParameter list.. 611 * @param i Index of the element to return. 612 * @return The element at position {@code i} in the TypeParameter list. 613 * @apilevel high-level 614 * @ast method 615 * 616 */ 617 @SuppressWarnings({"unchecked", "cast"}) 618 public TypeVariable getTypeParameter(int i) { 619 return (TypeVariable)getTypeParameterList().getChild(i); 620 } 621 /** 622 * Append an element to the TypeParameter list. 623 * @param node The element to append to the TypeParameter list. 624 * @apilevel high-level 625 * @ast method 626 * 627 */ 628 public void addTypeParameter(TypeVariable node) { 629 List<TypeVariable> list = (parent == null || state == null) ? getTypeParameterListNoTransform() : getTypeParameterList(); 630 list.addChild(node); 631 } 632 /** 633 * @apilevel low-level 634 * @ast method 635 * 636 */ 637 public void addTypeParameterNoTransform(TypeVariable node) { 638 List<TypeVariable> list = getTypeParameterListNoTransform(); 639 list.addChild(node); 640 } 641 /** 642 * Replaces the TypeParameter list element at index {@code i} with the new node {@code node}. 643 * @param node The new node to replace the old list element. 644 * @param i The list index of the node to be replaced. 645 * @apilevel high-level 646 * @ast method 647 * 648 */ 649 public void setTypeParameter(TypeVariable node, int i) { 650 List<TypeVariable> list = getTypeParameterList(); 651 list.setChild(node, i); 652 } 653 /** 654 * Retrieves the TypeParameter list. 655 * @return The node representing the TypeParameter list. 656 * @apilevel high-level 657 * @ast method 658 * 659 */ 660 public List<TypeVariable> getTypeParameters() { 661 return getTypeParameterList(); 662 } 663 /** 664 * Retrieves the TypeParameter list. 665 * <p><em>This method does not invoke AST transformations.</em></p> 666 * @return The node representing the TypeParameter list. 667 * @apilevel low-level 668 * @ast method 669 * 670 */ 671 public List<TypeVariable> getTypeParametersNoTransform() { 672 return getTypeParameterListNoTransform(); 673 } 674 /** 675 * Retrieves the TypeParameter list. 676 * @return The node representing the TypeParameter list. 677 * @apilevel high-level 678 * @ast method 679 * 680 */ 681 @SuppressWarnings({"unchecked", "cast"}) 682 public List<TypeVariable> getTypeParameterList() { 683 List<TypeVariable> list = (List<TypeVariable>)getChild(3); 684 list.getNumChild(); 685 return list; 686 } 687 /** 688 * Retrieves the TypeParameter list. 689 * <p><em>This method does not invoke AST transformations.</em></p> 690 * @return The node representing the TypeParameter list. 691 * @apilevel low-level 692 * @ast method 693 * 694 */ 695 @SuppressWarnings({"unchecked", "cast"}) 696 public List<TypeVariable> getTypeParameterListNoTransform() { 697 return (List<TypeVariable>)getChildNoTransform(3); 698 } 699 /** 700 * @apilevel internal 701 */ 702 protected boolean rawType_computed = false; 703 /** 704 * @apilevel internal 705 */ 706 protected TypeDecl rawType_value; 707 /** 708 * @attribute syn 709 * @aspect Generics 710 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:177 711 */ 712 @SuppressWarnings({"unchecked", "cast"}) 713 public TypeDecl rawType() { 714 if(rawType_computed) { 715 return rawType_value; 716 } 717 ASTNode$State state = state(); 718 int num = state.boundariesCrossed; 719 boolean isFinal = this.is$Final(); 720 rawType_value = rawType_compute(); 721 if(isFinal && num == state().boundariesCrossed){ rawType_computed = true; } 722 return rawType_value; 723 } 724 /** 725 * @apilevel internal 726 */ 727 private TypeDecl rawType_compute() { return lookupParTypeDecl(new ArrayList()); } 728 /** 729 * @apilevel internal 730 */ 731 protected java.util.Map lookupParTypeDecl_ArrayList_values; 732 /** 733 * @apilevel internal 734 */ 735 protected List lookupParTypeDecl_ArrayList_list; 736 /** 737 * @attribute syn 738 * @aspect LookupParTypeDecl 739 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:734 740 */ 741 @SuppressWarnings({"unchecked", "cast"}) 742 public TypeDecl lookupParTypeDecl(ArrayList list) { 743 Object _parameters = list; 744 if(lookupParTypeDecl_ArrayList_values == null) lookupParTypeDecl_ArrayList_values = new java.util.HashMap(4); 745 if(lookupParTypeDecl_ArrayList_values.containsKey(_parameters)) { 746 return (TypeDecl)lookupParTypeDecl_ArrayList_values.get(_parameters); 747 } 748 ASTNode$State state = state(); 749 int num = state.boundariesCrossed; 750 boolean isFinal = this.is$Final(); 751 TypeDecl lookupParTypeDecl_ArrayList_value = lookupParTypeDecl_compute(list); 752 if(lookupParTypeDecl_ArrayList_list == null) { 753 lookupParTypeDecl_ArrayList_list = new List(); 754 lookupParTypeDecl_ArrayList_list.is$Final = true; 755 lookupParTypeDecl_ArrayList_list.setParent(this); 756 } 757 lookupParTypeDecl_ArrayList_list.add(lookupParTypeDecl_ArrayList_value); 758 if(lookupParTypeDecl_ArrayList_value != null) { 759 lookupParTypeDecl_ArrayList_value = (TypeDecl)lookupParTypeDecl_ArrayList_list.getChild(lookupParTypeDecl_ArrayList_list.numChildren-1); 760 lookupParTypeDecl_ArrayList_value.is$Final = true; 761 } 762 if(true){ lookupParTypeDecl_ArrayList_values.put(_parameters, lookupParTypeDecl_ArrayList_value); } 763 return lookupParTypeDecl_ArrayList_value; 764 } 765 /** 766 * @apilevel internal 767 */ 768 private TypeDecl lookupParTypeDecl_compute(ArrayList list) { 769 /* 770 int size = createParTypeDeclStub_ArrayList_list != null ? createParTypeDeclStub_ArrayList_list.numChildren : 0; 771 ParInterfaceDecl typeDecl = (ParInterfaceDecl)createParTypeDeclStub(list); 772 if (size < createParTypeDeclStub_ArrayList_list.numChildren) { 773 createParTypeDeclBody(list, typeDecl); 774 } 775 return typeDecl; 776 */ 777 778 ParInterfaceDecl typeDecl = list.size() == 0 ? new RawInterfaceDecl() : new ParInterfaceDecl(); 779 typeDecl.setModifiers((Modifiers)getModifiers().fullCopy()); 780 typeDecl.setID(getID()); 781 // ES: trying to only so this for ParInterfaceDecl and then later for RawInterfaceDecl 782 if (!(typeDecl instanceof RawInterfaceDecl)) 783 typeDecl.setArgumentList(createArgumentList(list)); 784 return typeDecl; 785 786 } 787 /** 788 * @apilevel internal 789 */ 790 protected int usesTypeVariable_visited = -1; 791 /** 792 * @apilevel internal 793 */ 794 protected boolean usesTypeVariable_computed = false; 795 /** 796 * @apilevel internal 797 */ 798 protected boolean usesTypeVariable_initialized = false; 799 /** 800 * @apilevel internal 801 */ 802 protected boolean usesTypeVariable_value; 803 /** 804 * @attribute syn 805 * @aspect LookupParTypeDecl 806 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:1078 807 */ 808 @SuppressWarnings({"unchecked", "cast"}) 809 public boolean usesTypeVariable() { 810 if(usesTypeVariable_computed) { 811 return usesTypeVariable_value; 812 } 813 ASTNode$State state = state(); 814 if (!usesTypeVariable_initialized) { 815 usesTypeVariable_initialized = true; 816 usesTypeVariable_value = false; 817 } 818 if (!state.IN_CIRCLE) { 819 state.IN_CIRCLE = true; 820 int num = state.boundariesCrossed; 821 boolean isFinal = this.is$Final(); 822 do { 823 usesTypeVariable_visited = state.CIRCLE_INDEX; 824 state.CHANGE = false; 825 boolean new_usesTypeVariable_value = usesTypeVariable_compute(); 826 if (new_usesTypeVariable_value!=usesTypeVariable_value) 827 state.CHANGE = true; 828 usesTypeVariable_value = new_usesTypeVariable_value; 829 state.CIRCLE_INDEX++; 830 } while (state.CHANGE); 831 if(isFinal && num == state().boundariesCrossed) { 832 usesTypeVariable_computed = true; 833 } 834 else { 835 state.RESET_CYCLE = true; 836 usesTypeVariable_compute(); 837 state.RESET_CYCLE = false; 838 usesTypeVariable_computed = false; 839 usesTypeVariable_initialized = false; 840 } 841 state.IN_CIRCLE = false; 842 return usesTypeVariable_value; 843 } 844 if(usesTypeVariable_visited != state.CIRCLE_INDEX) { 845 usesTypeVariable_visited = state.CIRCLE_INDEX; 846 if (state.RESET_CYCLE) { 847 usesTypeVariable_computed = false; 848 usesTypeVariable_initialized = false; 849 usesTypeVariable_visited = -1; 850 return usesTypeVariable_value; 851 } 852 boolean new_usesTypeVariable_value = usesTypeVariable_compute(); 853 if (new_usesTypeVariable_value!=usesTypeVariable_value) 854 state.CHANGE = true; 855 usesTypeVariable_value = new_usesTypeVariable_value; 856 return usesTypeVariable_value; 857 } 858 return usesTypeVariable_value; 859 } 860 /** 861 * @apilevel internal 862 */ 863 private boolean usesTypeVariable_compute() { return true; } 864 protected java.util.Map subtype_TypeDecl_values; 865 /** 866 * @attribute syn 867 * @aspect GenericsSubtype 868 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:19 869 */ 870 @SuppressWarnings({"unchecked", "cast"}) 871 public boolean subtype(TypeDecl type) { 872 Object _parameters = type; 873 if(subtype_TypeDecl_values == null) subtype_TypeDecl_values = new java.util.HashMap(4); 874 ASTNode$State.CircularValue _value; 875 if(subtype_TypeDecl_values.containsKey(_parameters)) { 876 Object _o = subtype_TypeDecl_values.get(_parameters); 877 if(!(_o instanceof ASTNode$State.CircularValue)) { 878 return ((Boolean)_o).booleanValue(); 879 } 880 else 881 _value = (ASTNode$State.CircularValue)_o; 882 } 883 else { 884 _value = new ASTNode$State.CircularValue(); 885 subtype_TypeDecl_values.put(_parameters, _value); 886 _value.value = Boolean.valueOf(true); 887 } 888 ASTNode$State state = state(); 889 if (!state.IN_CIRCLE) { 890 state.IN_CIRCLE = true; 891 int num = state.boundariesCrossed; 892 boolean isFinal = this.is$Final(); 893 boolean new_subtype_TypeDecl_value; 894 do { 895 _value.visited = new Integer(state.CIRCLE_INDEX); 896 state.CHANGE = false; 897 new_subtype_TypeDecl_value = subtype_compute(type); 898 if (new_subtype_TypeDecl_value!=((Boolean)_value.value).booleanValue()) { 899 state.CHANGE = true; 900 _value.value = Boolean.valueOf(new_subtype_TypeDecl_value); 901 } 902 state.CIRCLE_INDEX++; 903 } while (state.CHANGE); 904 if(isFinal && num == state().boundariesCrossed) { 905 subtype_TypeDecl_values.put(_parameters, new_subtype_TypeDecl_value); 906 } 907 else { 908 subtype_TypeDecl_values.remove(_parameters); 909 state.RESET_CYCLE = true; 910 subtype_compute(type); 911 state.RESET_CYCLE = false; 912 } 913 state.IN_CIRCLE = false; 914 return new_subtype_TypeDecl_value; 915 } 916 if(!new Integer(state.CIRCLE_INDEX).equals(_value.visited)) { 917 _value.visited = new Integer(state.CIRCLE_INDEX); 918 boolean new_subtype_TypeDecl_value = subtype_compute(type); 919 if (state.RESET_CYCLE) { 920 subtype_TypeDecl_values.remove(_parameters); 921 } 922 else if (new_subtype_TypeDecl_value!=((Boolean)_value.value).booleanValue()) { 923 state.CHANGE = true; 924 _value.value = new_subtype_TypeDecl_value; 925 } 926 return new_subtype_TypeDecl_value; 927 } 928 return ((Boolean)_value.value).booleanValue(); 929 } 930 /** 931 * @apilevel internal 932 */ 933 private boolean subtype_compute(TypeDecl type) { return type.supertypeGenericInterfaceDecl(this); } 934 /** 935 * @attribute syn 936 * @aspect GenericsSubtype 937 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:125 938 */ 939 public boolean supertypeParClassDecl(ParClassDecl type) { 940 ASTNode$State state = state(); 941 try { return type.genericDecl().original().subtype(this); } 942 finally { 943 } 944 } 945 /** 946 * @attribute syn 947 * @aspect GenericsSubtype 948 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:129 949 */ 950 public boolean supertypeParInterfaceDecl(ParInterfaceDecl type) { 951 ASTNode$State state = state(); 952 try { return type.genericDecl().original().subtype(this); } 953 finally { 954 } 955 } 956 protected java.util.Map instanceOf_TypeDecl_values; 957 /** 958 * @attribute syn 959 * @aspect GenericsSubtype 960 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:395 961 */ 962 @SuppressWarnings({"unchecked", "cast"}) 963 public boolean instanceOf(TypeDecl type) { 964 Object _parameters = type; 965 if(instanceOf_TypeDecl_values == null) instanceOf_TypeDecl_values = new java.util.HashMap(4); 966 if(instanceOf_TypeDecl_values.containsKey(_parameters)) { 967 return ((Boolean)instanceOf_TypeDecl_values.get(_parameters)).booleanValue(); 968 } 969 ASTNode$State state = state(); 970 int num = state.boundariesCrossed; 971 boolean isFinal = this.is$Final(); 972 boolean instanceOf_TypeDecl_value = instanceOf_compute(type); 973 if(isFinal && num == state().boundariesCrossed){ instanceOf_TypeDecl_values.put(_parameters, Boolean.valueOf(instanceOf_TypeDecl_value)); } 974 return instanceOf_TypeDecl_value; 975 } 976 /** 977 * @apilevel internal 978 */ 979 private boolean instanceOf_compute(TypeDecl type) { return subtype(type); } 980 /** 981 * @apilevel internal 982 */ 983 protected boolean constantPoolName_computed = false; 984 /** 985 * @apilevel internal 986 */ 987 protected String constantPoolName_value; 988 /** 989 * @attribute syn 990 * @aspect GenericsCodegen 991 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/GenericsCodegen.jrag:194 992 */ 993 @SuppressWarnings({"unchecked", "cast"}) 994 public String constantPoolName() { 995 if(constantPoolName_computed) { 996 return constantPoolName_value; 997 } 998 ASTNode$State state = state(); 999 int num = state.boundariesCrossed; 1000 boolean isFinal = this.is$Final(); 1001 constantPoolName_value = constantPoolName_compute(); 1002 if(isFinal && num == state().boundariesCrossed){ constantPoolName_computed = true; } 1003 return constantPoolName_value; 1004 } 1005 /** 1006 * @apilevel internal 1007 */ 1008 private String constantPoolName_compute() { 1009 if(!isNestedType()) { 1010 String packageName = packageName(); 1011 if(!packageName.equals("")) { 1012 packageName = packageName.replace('.', '/') + "/"; 1013 } 1014 return packageName + getID(); 1015 } 1016 else { 1017 String prefix = enclosingType().constantPoolName(); 1018 if(isAnonymous()) { 1019 return prefix + "$" + uniqueIndex(); 1020 } 1021 else if(isLocalClass()) { 1022 return prefix + "$" + uniqueIndex() + getID(); 1023 } 1024 return prefix + "$" + getID(); 1025 } 1026 } 1027 /** 1028 * @apilevel internal 1029 */ 1030 protected boolean needsSignatureAttribute_computed = false; 1031 /** 1032 * @apilevel internal 1033 */ 1034 protected boolean needsSignatureAttribute_value; 1035 /** 1036 * @attribute syn 1037 * @aspect GenericsCodegen 1038 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/GenericsCodegen.jrag:341 1039 */ 1040 @SuppressWarnings({"unchecked", "cast"}) 1041 public boolean needsSignatureAttribute() { 1042 if(needsSignatureAttribute_computed) { 1043 return needsSignatureAttribute_value; 1044 } 1045 ASTNode$State state = state(); 1046 int num = state.boundariesCrossed; 1047 boolean isFinal = this.is$Final(); 1048 needsSignatureAttribute_value = needsSignatureAttribute_compute(); 1049 if(isFinal && num == state().boundariesCrossed){ needsSignatureAttribute_computed = true; } 1050 return needsSignatureAttribute_value; 1051 } 1052 /** 1053 * @apilevel internal 1054 */ 1055 private boolean needsSignatureAttribute_compute() { return true; } 1056 /** 1057 * @apilevel internal 1058 */ 1059 protected boolean classSignature_computed = false; 1060 /** 1061 * @apilevel internal 1062 */ 1063 protected String classSignature_value; 1064 /** 1065 * @attribute syn 1066 * @aspect GenericsCodegen 1067 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/GenericsCodegen.jrag:414 1068 */ 1069 @SuppressWarnings({"unchecked", "cast"}) 1070 public String classSignature() { 1071 if(classSignature_computed) { 1072 return classSignature_value; 1073 } 1074 ASTNode$State state = state(); 1075 int num = state.boundariesCrossed; 1076 boolean isFinal = this.is$Final(); 1077 classSignature_value = classSignature_compute(); 1078 if(isFinal && num == state().boundariesCrossed){ classSignature_computed = true; } 1079 return classSignature_value; 1080 } 1081 /** 1082 * @apilevel internal 1083 */ 1084 private String classSignature_compute() { 1085 StringBuffer buf = new StringBuffer(); 1086 // FormalTypeParameters 1087 buf.append("<"); 1088 for(int i = 0; i < getNumTypeParameter(); i++) 1089 buf.append(getTypeParameter(i).formalTypeParameter()); 1090 buf.append(">"); 1091 buf.append(super.classSignature()); 1092 return buf.toString(); 1093 } 1094 /** 1095 * @attribute syn 1096 * @aspect Generics 1097 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:158 1098 */ 1099 public boolean isGenericType() { 1100 ASTNode$State state = state(); 1101 try { return true; } 1102 finally { 1103 } 1104 } 1105 protected java.util.Map lookupParTypeDecl_ParTypeAccess_values; 1106 /** 1107 * @attribute syn 1108 * @aspect LookupParTypeDecl 1109 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:708 1110 */ 1111 @SuppressWarnings({"unchecked", "cast"}) 1112 public TypeDecl lookupParTypeDecl(ParTypeAccess p) { 1113 Object _parameters = p; 1114 if(lookupParTypeDecl_ParTypeAccess_values == null) lookupParTypeDecl_ParTypeAccess_values = new java.util.HashMap(4); 1115 if(lookupParTypeDecl_ParTypeAccess_values.containsKey(_parameters)) { 1116 return (TypeDecl)lookupParTypeDecl_ParTypeAccess_values.get(_parameters); 1117 } 1118 ASTNode$State state = state(); 1119 int num = state.boundariesCrossed; 1120 boolean isFinal = this.is$Final(); 1121 TypeDecl lookupParTypeDecl_ParTypeAccess_value = lookupParTypeDecl_compute(p); 1122 if(isFinal && num == state().boundariesCrossed){ lookupParTypeDecl_ParTypeAccess_values.put(_parameters, lookupParTypeDecl_ParTypeAccess_value); } 1123 return lookupParTypeDecl_ParTypeAccess_value; 1124 } 1125 /** 1126 * @apilevel internal 1127 */ 1128 private TypeDecl lookupParTypeDecl_compute(ParTypeAccess p) { 1129 ArrayList typeArguments = new ArrayList(); 1130 for(int i = 0; i < p.getNumTypeArgument(); i++) 1131 typeArguments.add(p.getTypeArgument(i).type()); 1132 return lookupParTypeDecl(typeArguments); 1133 } 1134 /** 1135 * @attribute inh 1136 * @aspect GenericsTypeCheck 1137 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:436 1138 */ 1139 @SuppressWarnings({"unchecked", "cast"}) 1140 public TypeDecl typeThrowable() { 1141 ASTNode$State state = state(); 1142 TypeDecl typeThrowable_value = getParent().Define_TypeDecl_typeThrowable(this, null); 1143 return typeThrowable_value; 1144 } 1145 /** 1146 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:486 1147 * @apilevel internal 1148 */ 1149 public boolean Define_boolean_isNestedType(ASTNode caller, ASTNode child) { 1150 if(caller == getTypeParameterListNoTransform()) { 1151 int childIndex = caller.getIndexOfChild(child); 1152 return true; 1153 } 1154 else { return super.Define_boolean_isNestedType(caller, child); 1155 } 1156 } 1157 /** 1158 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:487 1159 * @apilevel internal 1160 */ 1161 public TypeDecl Define_TypeDecl_enclosingType(ASTNode caller, ASTNode child) { 1162 if(caller == getTypeParameterListNoTransform()) { 1163 int childIndex = caller.getIndexOfChild(child); 1164 return this; 1165 } 1166 else { return super.Define_TypeDecl_enclosingType(caller, child); 1167 } 1168 } 1169 /** 1170 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:531 1171 * @apilevel internal 1172 */ 1173 public SimpleSet Define_SimpleSet_lookupType(ASTNode caller, ASTNode child, String name) { 1174 if(caller == getBodyDeclListNoTransform()) { 1175 int index = caller.getIndexOfChild(child); 1176 { 1177 SimpleSet c = memberTypes(name); 1178 if(getBodyDecl(index).visibleTypeParameters()) 1179 c = addTypeVariables(c, name); 1180 if(!c.isEmpty()) 1181 return c; 1182 // 8.5.2 1183 if(isClassDecl() && isStatic() && !isTopLevelType()) { 1184 for(Iterator iter = lookupType(name).iterator(); iter.hasNext(); ) { 1185 TypeDecl d = (TypeDecl)iter.next(); 1186 if(d.isStatic() || (d.enclosingType() != null && instanceOf(d.enclosingType()))) { 1187 c = c.add(d); 1188 } 1189 } 1190 } 1191 else 1192 c = lookupType(name); 1193 if(!c.isEmpty()) 1194 return c; 1195 return topLevelType().lookupType(name); // Fix to search imports 1196 // include type parameters if not static 1197 } 1198 } 1199 else if(caller == getTypeParameterListNoTransform()) { 1200 int childIndex = caller.getIndexOfChild(child); 1201 { 1202 SimpleSet c = memberTypes(name); 1203 c = addTypeVariables(c, name); 1204 if(!c.isEmpty()) return c; 1205 // 8.5.2 1206 if(isClassDecl() && isStatic() && !isTopLevelType()) { 1207 for(Iterator iter = lookupType(name).iterator(); iter.hasNext(); ) { 1208 TypeDecl d = (TypeDecl)iter.next(); 1209 if(d.isStatic() || (d.enclosingType() != null && instanceOf(d.enclosingType()))) { 1210 c = c.add(d); 1211 } 1212 } 1213 } 1214 else 1215 c = lookupType(name); 1216 if(!c.isEmpty()) 1217 return c; 1218 return topLevelType().lookupType(name); // Fix to search imports 1219 } 1220 } 1221 else if(caller == getSuperInterfaceIdListNoTransform()) { 1222 int childIndex = caller.getIndexOfChild(child); 1223 { 1224 SimpleSet c = addTypeVariables(SimpleSet.emptySet, name); 1225 return !c.isEmpty() ? c : lookupType(name); 1226 } 1227 } 1228 else { return super.Define_SimpleSet_lookupType(caller, child, name); 1229 } 1230 } 1231 /** 1232 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsParTypeDecl.jrag:51 1233 * @apilevel internal 1234 */ 1235 public TypeDecl Define_TypeDecl_genericDecl(ASTNode caller, ASTNode child) { 1236 { 1237 int childIndex = this.getIndexOfChild(caller); 1238 return this; 1239 } 1240 } 1241 /** 1242 * @apilevel internal 1243 */ 1244 public ASTNode rewriteTo() { 1245 return super.rewriteTo(); 1246 } 1247 }