001 /* This file was generated with JastAdd2 (http://jastadd.org) version R20130213 */ 002 package AST; 003 004 import java.util.HashSet; 005 import java.io.File; 006 import java.util.*; 007 import beaver.*; 008 import java.util.ArrayList; 009 import java.util.zip.*; 010 import java.io.*; 011 import java.io.FileNotFoundException; 012 import java.util.Collection; 013 /** 014 * @production TypeVariable : {@link ReferenceType} ::= <span class="component">{@link Modifiers}</span> <span class="component"><ID:String></span> <span class="component">{@link BodyDecl}*</span> <span class="component">TypeBound:{@link Access}*</span>; 015 * @ast node 016 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.ast:18 017 */ 018 public class TypeVariable extends ReferenceType implements Cloneable { 019 /** 020 * @apilevel low-level 021 */ 022 public void flushCache() { 023 } 024 /** 025 * @apilevel internal 026 */ 027 public void flushCollectionCache() { 028 } 029 /** 030 * @apilevel internal 031 */ 032 @SuppressWarnings({"unchecked", "cast"}) 033 public TypeVariable clone() throws CloneNotSupportedException { 034 TypeVariable node = (TypeVariable)super.clone(); 035 node.toInterface_computed = false; 036 node.toInterface_value = null; 037 node.involvesTypeParameters_visited = -1; 038 node.involvesTypeParameters_computed = false; 039 node.involvesTypeParameters_initialized = false; 040 node.memberFields_String_values = null; 041 node.castingConversionTo_TypeDecl_values = null; 042 node.erasure_computed = false; 043 node.erasure_value = null; 044 node.fullName_computed = false; 045 node.fullName_value = null; 046 node.lubType_computed = false; 047 node.lubType_value = null; 048 node.usesTypeVariable_visited = -1; 049 node.usesTypeVariable_computed = false; 050 node.usesTypeVariable_initialized = false; 051 node.accessibleFrom_TypeDecl_values = null; 052 node.typeName_computed = false; 053 node.typeName_value = null; 054 node.sameStructure_TypeDecl_values = null; 055 node.subtype_TypeDecl_values = null; 056 node.getSubstitutedTypeBound_int_TypeDecl_values = null; 057 node.instanceOf_TypeDecl_values = null; 058 node.typeDescriptor_computed = false; 059 node.typeDescriptor_value = null; 060 node.constantPoolName_computed = false; 061 node.constantPoolName_value = null; 062 node.needsSignatureAttribute_computed = false; 063 node.fieldTypeSignature_computed = false; 064 node.fieldTypeSignature_value = null; 065 node.classTypeSignature_computed = false; 066 node.classTypeSignature_value = null; 067 node.classBound_computed = false; 068 node.classBound_value = null; 069 node.interfaceBounds_computed = false; 070 node.interfaceBounds_value = null; 071 node.in$Circle(false); 072 node.is$Final(false); 073 return node; 074 } 075 /** 076 * @apilevel internal 077 */ 078 @SuppressWarnings({"unchecked", "cast"}) 079 public TypeVariable copy() { 080 081 try { 082 TypeVariable node = (TypeVariable) clone(); 083 node.parent = null; 084 if(children != null) 085 node.children = (ASTNode[]) children.clone(); 086 087 return node; 088 } catch (CloneNotSupportedException e) { 089 throw new Error("Error: clone not supported for " + getClass().getName()); 090 } 091 092 }/** 093 * Create a deep copy of the AST subtree at this node. 094 * The copy is dangling, i.e. has no parent. 095 * @return dangling copy of the subtree at this node 096 * @apilevel low-level 097 */ 098 @SuppressWarnings({"unchecked", "cast"}) 099 public TypeVariable fullCopy() { 100 101 TypeVariable tree = (TypeVariable) copy(); 102 if (children != null) { 103 for (int i = 0; i < children.length; ++i) { 104 105 ASTNode child = (ASTNode) children[i]; 106 if(child != null) { 107 child = child.fullCopy(); 108 tree.setChild(child, i); 109 } 110 } 111 } 112 return tree; 113 114 } /** 115 * @ast method 116 * @aspect GenericTypeVariables 117 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericTypeVariables.jrag:28 118 */ 119 public void nameCheck() { 120 if(extractSingleType(lookupType(name())) != this) 121 error("*** Semantic Error: type variable " + name() + " is multiply declared"); 122 } 123 /** 124 * @ast method 125 * @aspect GenricTypeVariablesTypeAnalysis 126 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericTypeVariables.jrag:66 127 */ 128 public void typeCheck() { 129 if(!getTypeBound(0).type().isTypeVariable() && !getTypeBound(0).type().isClassDecl() && !getTypeBound(0).type().isInterfaceDecl()) { 130 error("the first type bound must be either a type variable, or a class or interface type which " + 131 getTypeBound(0).type().fullName() + " is not"); 132 } 133 for(int i = 1; i < getNumTypeBound(); i++) { 134 if(!getTypeBound(i).type().isInterfaceDecl()) { 135 error("type bound " + i + " must be an interface type which " + 136 getTypeBound(i).type().fullName() + " is not"); 137 } 138 } 139 HashSet typeSet = new HashSet(); 140 for(int i = 0; i < getNumTypeBound(); i++) { 141 TypeDecl type = getTypeBound(i).type(); 142 TypeDecl erasure = type.erasure(); 143 if(typeSet.contains(erasure)) { 144 if(type != erasure) { 145 error("the erasure " + erasure.fullName() + " of typebound " + getTypeBound(i) + " is multiply declared in " + this); 146 } 147 else { 148 error(type.fullName() + " is multiply declared"); 149 } 150 } 151 typeSet.add(erasure); 152 } 153 154 for(int i = 0; i < getNumTypeBound(); i++) { 155 TypeDecl type = getTypeBound(i).type(); 156 for(Iterator iter = type.methodsIterator(); iter.hasNext(); ) { 157 MethodDecl m = (MethodDecl)iter.next(); 158 for(int j = i+1; j < getNumTypeBound(); j++) { 159 TypeDecl destType = getTypeBound(j).type(); 160 for(Iterator destIter = destType.memberMethods(m.name()).iterator(); destIter.hasNext(); ) { 161 MethodDecl n = (MethodDecl)destIter.next(); 162 if(m.sameSignature(n) && m.type() != n.type()) { 163 error("the two bounds, " + type.name() + " and " + destType.name() + ", in type variable " + name() + 164 " have a method " + m.signature() + " with conflicting return types " + m.type().name() + " and " + n.type().name()); 165 } 166 } 167 } 168 } 169 } 170 171 172 } 173 /** 174 * @ast method 175 * @aspect LookupParTypeDecl 176 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:883 177 */ 178 public Access substitute(Parameterization parTypeDecl) { 179 if(parTypeDecl.isRawType()) 180 return erasure().createBoundAccess(); 181 return parTypeDecl.substitute(this).createBoundAccess(); 182 } 183 /** 184 * @ast method 185 * @aspect LookupParTypeDecl 186 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:928 187 */ 188 public Access substituteReturnType(Parameterization parTypeDecl) { 189 if(parTypeDecl.isRawType()) 190 return erasure().createBoundAccess(); 191 TypeDecl typeDecl = parTypeDecl.substitute(this); 192 if(typeDecl instanceof WildcardType) { 193 // the bound of this type variable 194 return createBoundAccess(); 195 //return lubType().createBoundAccess(); 196 //return typeObject().createBoundAccess(); 197 } 198 else if(typeDecl instanceof WildcardExtendsType) { 199 if(typeDecl.instanceOf(this)) 200 return ((WildcardExtendsType)typeDecl).extendsType().createBoundAccess(); 201 else 202 return createBoundAccess(); 203 204 // the bound of this type variable of the bound of the wild card if it is more specific 205 //return ((WildcardExtendsType)typeDecl).extendsType().createBoundAccess(); 206 } 207 else if(typeDecl instanceof WildcardSuperType) { 208 // the bound of this type variable 209 return createBoundAccess(); 210 //return typeObject().createBoundAccess(); 211 } 212 return typeDecl.createBoundAccess(); 213 } 214 /** 215 * @ast method 216 * @aspect LookupParTypeDecl 217 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:962 218 */ 219 public Access substituteParameterType(Parameterization parTypeDecl) { 220 if(parTypeDecl.isRawType()) 221 return erasure().createBoundAccess(); 222 TypeDecl typeDecl = parTypeDecl.substitute(this); 223 if(typeDecl instanceof WildcardType) 224 return typeNull().createQualifiedAccess(); 225 else if(typeDecl instanceof WildcardExtendsType) 226 return typeNull().createQualifiedAccess(); 227 else if(typeDecl instanceof WildcardSuperType) 228 return ((WildcardSuperType)typeDecl).superType().createBoundAccess(); 229 return typeDecl.createBoundAccess(); 230 } 231 /** 232 * @ast method 233 * @aspect NewGenerics 234 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:1495 235 */ 236 public Access createQualifiedAccess() { 237 return createBoundAccess(); 238 } 239 /** 240 * @ast method 241 * @aspect GenericsPrettyPrint 242 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsPrettyPrint.jrag:11 243 */ 244 public void toString(StringBuffer s) { 245 s.append(name()); 246 if(getNumTypeBound() > 0) { 247 s.append(" extends "); 248 s.append(getTypeBound(0).type().fullName()); 249 for(int i = 1; i < getNumTypeBound(); i++) { 250 s.append(" & "); 251 s.append(getTypeBound(i).type().fullName()); 252 } 253 } 254 } 255 /** 256 * @ast method 257 * 258 */ 259 public TypeVariable() { 260 super(); 261 262 263 } 264 /** 265 * Initializes the child array to the correct size. 266 * Initializes List and Opt nta children. 267 * @apilevel internal 268 * @ast method 269 * @ast method 270 * 271 */ 272 public void init$Children() { 273 children = new ASTNode[3]; 274 setChild(new List(), 1); 275 setChild(new List(), 2); 276 } 277 /** 278 * @ast method 279 * 280 */ 281 public TypeVariable(Modifiers p0, String p1, List<BodyDecl> p2, List<Access> p3) { 282 setChild(p0, 0); 283 setID(p1); 284 setChild(p2, 1); 285 setChild(p3, 2); 286 } 287 /** 288 * @ast method 289 * 290 */ 291 public TypeVariable(Modifiers p0, beaver.Symbol p1, List<BodyDecl> p2, List<Access> p3) { 292 setChild(p0, 0); 293 setID(p1); 294 setChild(p2, 1); 295 setChild(p3, 2); 296 } 297 /** 298 * @apilevel low-level 299 * @ast method 300 * 301 */ 302 protected int numChildren() { 303 return 3; 304 } 305 /** 306 * @apilevel internal 307 * @ast method 308 * 309 */ 310 public boolean mayHaveRewrite() { 311 return true; 312 } 313 /** 314 * Replaces the Modifiers child. 315 * @param node The new node to replace the Modifiers child. 316 * @apilevel high-level 317 * @ast method 318 * 319 */ 320 public void setModifiers(Modifiers node) { 321 setChild(node, 0); 322 } 323 /** 324 * Retrieves the Modifiers child. 325 * @return The current node used as the Modifiers child. 326 * @apilevel high-level 327 * @ast method 328 * 329 */ 330 public Modifiers getModifiers() { 331 return (Modifiers)getChild(0); 332 } 333 /** 334 * Retrieves the Modifiers child. 335 * <p><em>This method does not invoke AST transformations.</em></p> 336 * @return The current node used as the Modifiers child. 337 * @apilevel low-level 338 * @ast method 339 * 340 */ 341 public Modifiers getModifiersNoTransform() { 342 return (Modifiers)getChildNoTransform(0); 343 } 344 /** 345 * Replaces the lexeme ID. 346 * @param value The new value for the lexeme ID. 347 * @apilevel high-level 348 * @ast method 349 * 350 */ 351 public void setID(String value) { 352 tokenString_ID = value; 353 } 354 /** 355 * JastAdd-internal setter for lexeme ID using the Beaver parser. 356 * @apilevel internal 357 * @ast method 358 * 359 */ 360 public void setID(beaver.Symbol symbol) { 361 if(symbol.value != null && !(symbol.value instanceof String)) 362 throw new UnsupportedOperationException("setID is only valid for String lexemes"); 363 tokenString_ID = (String)symbol.value; 364 IDstart = symbol.getStart(); 365 IDend = symbol.getEnd(); 366 } 367 /** 368 * Retrieves the value for the lexeme ID. 369 * @return The value for the lexeme ID. 370 * @apilevel high-level 371 * @ast method 372 * 373 */ 374 public String getID() { 375 return tokenString_ID != null ? tokenString_ID : ""; 376 } 377 /** 378 * Replaces the BodyDecl list. 379 * @param list The new list node to be used as the BodyDecl list. 380 * @apilevel high-level 381 * @ast method 382 * 383 */ 384 public void setBodyDeclList(List<BodyDecl> list) { 385 setChild(list, 1); 386 } 387 /** 388 * Retrieves the number of children in the BodyDecl list. 389 * @return Number of children in the BodyDecl list. 390 * @apilevel high-level 391 * @ast method 392 * 393 */ 394 public int getNumBodyDecl() { 395 return getBodyDeclList().getNumChild(); 396 } 397 /** 398 * Retrieves the number of children in the BodyDecl list. 399 * Calling this method will not trigger rewrites.. 400 * @return Number of children in the BodyDecl list. 401 * @apilevel low-level 402 * @ast method 403 * 404 */ 405 public int getNumBodyDeclNoTransform() { 406 return getBodyDeclListNoTransform().getNumChildNoTransform(); 407 } 408 /** 409 * Retrieves the element at index {@code i} in the BodyDecl list.. 410 * @param i Index of the element to return. 411 * @return The element at position {@code i} in the BodyDecl list. 412 * @apilevel high-level 413 * @ast method 414 * 415 */ 416 @SuppressWarnings({"unchecked", "cast"}) 417 public BodyDecl getBodyDecl(int i) { 418 return (BodyDecl)getBodyDeclList().getChild(i); 419 } 420 /** 421 * Append an element to the BodyDecl list. 422 * @param node The element to append to the BodyDecl list. 423 * @apilevel high-level 424 * @ast method 425 * 426 */ 427 public void addBodyDecl(BodyDecl node) { 428 List<BodyDecl> list = (parent == null || state == null) ? getBodyDeclListNoTransform() : getBodyDeclList(); 429 list.addChild(node); 430 } 431 /** 432 * @apilevel low-level 433 * @ast method 434 * 435 */ 436 public void addBodyDeclNoTransform(BodyDecl node) { 437 List<BodyDecl> list = getBodyDeclListNoTransform(); 438 list.addChild(node); 439 } 440 /** 441 * Replaces the BodyDecl list element at index {@code i} with the new node {@code node}. 442 * @param node The new node to replace the old list element. 443 * @param i The list index of the node to be replaced. 444 * @apilevel high-level 445 * @ast method 446 * 447 */ 448 public void setBodyDecl(BodyDecl node, int i) { 449 List<BodyDecl> list = getBodyDeclList(); 450 list.setChild(node, i); 451 } 452 /** 453 * Retrieves the BodyDecl list. 454 * @return The node representing the BodyDecl list. 455 * @apilevel high-level 456 * @ast method 457 * 458 */ 459 public List<BodyDecl> getBodyDecls() { 460 return getBodyDeclList(); 461 } 462 /** 463 * Retrieves the BodyDecl list. 464 * <p><em>This method does not invoke AST transformations.</em></p> 465 * @return The node representing the BodyDecl list. 466 * @apilevel low-level 467 * @ast method 468 * 469 */ 470 public List<BodyDecl> getBodyDeclsNoTransform() { 471 return getBodyDeclListNoTransform(); 472 } 473 /** 474 * Retrieves the BodyDecl list. 475 * @return The node representing the BodyDecl list. 476 * @apilevel high-level 477 * @ast method 478 * 479 */ 480 @SuppressWarnings({"unchecked", "cast"}) 481 public List<BodyDecl> getBodyDeclList() { 482 List<BodyDecl> list = (List<BodyDecl>)getChild(1); 483 list.getNumChild(); 484 return list; 485 } 486 /** 487 * Retrieves the BodyDecl list. 488 * <p><em>This method does not invoke AST transformations.</em></p> 489 * @return The node representing the BodyDecl list. 490 * @apilevel low-level 491 * @ast method 492 * 493 */ 494 @SuppressWarnings({"unchecked", "cast"}) 495 public List<BodyDecl> getBodyDeclListNoTransform() { 496 return (List<BodyDecl>)getChildNoTransform(1); 497 } 498 /** 499 * Replaces the TypeBound list. 500 * @param list The new list node to be used as the TypeBound list. 501 * @apilevel high-level 502 * @ast method 503 * 504 */ 505 public void setTypeBoundList(List<Access> list) { 506 setChild(list, 2); 507 } 508 /** 509 * Retrieves the number of children in the TypeBound list. 510 * @return Number of children in the TypeBound list. 511 * @apilevel high-level 512 * @ast method 513 * 514 */ 515 public int getNumTypeBound() { 516 return getTypeBoundList().getNumChild(); 517 } 518 /** 519 * Retrieves the number of children in the TypeBound list. 520 * Calling this method will not trigger rewrites.. 521 * @return Number of children in the TypeBound list. 522 * @apilevel low-level 523 * @ast method 524 * 525 */ 526 public int getNumTypeBoundNoTransform() { 527 return getTypeBoundListNoTransform().getNumChildNoTransform(); 528 } 529 /** 530 * Retrieves the element at index {@code i} in the TypeBound list.. 531 * @param i Index of the element to return. 532 * @return The element at position {@code i} in the TypeBound list. 533 * @apilevel high-level 534 * @ast method 535 * 536 */ 537 @SuppressWarnings({"unchecked", "cast"}) 538 public Access getTypeBound(int i) { 539 return (Access)getTypeBoundList().getChild(i); 540 } 541 /** 542 * Append an element to the TypeBound list. 543 * @param node The element to append to the TypeBound list. 544 * @apilevel high-level 545 * @ast method 546 * 547 */ 548 public void addTypeBound(Access node) { 549 List<Access> list = (parent == null || state == null) ? getTypeBoundListNoTransform() : getTypeBoundList(); 550 list.addChild(node); 551 } 552 /** 553 * @apilevel low-level 554 * @ast method 555 * 556 */ 557 public void addTypeBoundNoTransform(Access node) { 558 List<Access> list = getTypeBoundListNoTransform(); 559 list.addChild(node); 560 } 561 /** 562 * Replaces the TypeBound list element at index {@code i} with the new node {@code node}. 563 * @param node The new node to replace the old list element. 564 * @param i The list index of the node to be replaced. 565 * @apilevel high-level 566 * @ast method 567 * 568 */ 569 public void setTypeBound(Access node, int i) { 570 List<Access> list = getTypeBoundList(); 571 list.setChild(node, i); 572 } 573 /** 574 * Retrieves the TypeBound list. 575 * @return The node representing the TypeBound list. 576 * @apilevel high-level 577 * @ast method 578 * 579 */ 580 public List<Access> getTypeBounds() { 581 return getTypeBoundList(); 582 } 583 /** 584 * Retrieves the TypeBound list. 585 * <p><em>This method does not invoke AST transformations.</em></p> 586 * @return The node representing the TypeBound list. 587 * @apilevel low-level 588 * @ast method 589 * 590 */ 591 public List<Access> getTypeBoundsNoTransform() { 592 return getTypeBoundListNoTransform(); 593 } 594 /** 595 * Retrieves the TypeBound list. 596 * @return The node representing the TypeBound list. 597 * @apilevel high-level 598 * @ast method 599 * 600 */ 601 @SuppressWarnings({"unchecked", "cast"}) 602 public List<Access> getTypeBoundList() { 603 List<Access> list = (List<Access>)getChild(2); 604 list.getNumChild(); 605 return list; 606 } 607 /** 608 * Retrieves the TypeBound list. 609 * <p><em>This method does not invoke AST transformations.</em></p> 610 * @return The node representing the TypeBound list. 611 * @apilevel low-level 612 * @ast method 613 * 614 */ 615 @SuppressWarnings({"unchecked", "cast"}) 616 public List<Access> getTypeBoundListNoTransform() { 617 return (List<Access>)getChildNoTransform(2); 618 } 619 /** 620 * @apilevel internal 621 */ 622 protected boolean toInterface_computed = false; 623 /** 624 * @apilevel internal 625 */ 626 protected TypeDecl toInterface_value; 627 /** 628 * @attribute syn 629 * @aspect GreatestLowerBoundFactory 630 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GLBTypeFactory.jadd:12 631 */ 632 @SuppressWarnings({"unchecked", "cast"}) 633 public TypeDecl toInterface() { 634 if(toInterface_computed) { 635 return toInterface_value; 636 } 637 ASTNode$State state = state(); 638 int num = state.boundariesCrossed; 639 boolean isFinal = this.is$Final(); 640 toInterface_value = toInterface_compute(); 641 toInterface_value.setParent(this); 642 toInterface_value.is$Final = true; 643 if(true){ toInterface_computed = true; } 644 return toInterface_value; 645 } 646 /** 647 * @apilevel internal 648 */ 649 private TypeDecl toInterface_compute() { 650 // convert var to interface 651 InterfaceDecl ITj = new InterfaceDecl(); 652 ITj.setID("ITj_" + hashCode()); 653 // I'm assuming that TypeVariable has no members of it's own. 654 // TODO: would it be enough to add only public members of a bound 655 // that is TypeVariable or ClassDecl and add other (interface) 656 // bounds as superinterfaces to ITj 657 // TODO: Is it really necessary to add public members to the new 658 // interface? Or is an empty interface more than enough since java 659 // has a nominal type system. 660 for (int i = 0; i < getNumTypeBound(); i++) { 661 TypeDecl bound = getTypeBound(i).type(); 662 for (int j = 0; j < bound.getNumBodyDecl(); j++) { 663 BodyDecl bd = bound.getBodyDecl(j); 664 if (bd instanceof FieldDeclaration) { 665 FieldDeclaration fd = (FieldDeclaration) bd.fullCopy(); 666 if (fd.isPublic()) 667 ITj.addBodyDecl(fd); 668 } 669 else if (bd instanceof MethodDecl) { 670 MethodDecl md = (MethodDecl) bd; 671 if (md.isPublic()) 672 ITj.addBodyDecl((BodyDecl)md.fullCopy()); 673 } 674 } 675 } 676 return ITj; 677 } 678 /** 679 * @apilevel internal 680 */ 681 protected int involvesTypeParameters_visited = -1; 682 /** 683 * @apilevel internal 684 */ 685 protected boolean involvesTypeParameters_computed = false; 686 /** 687 * @apilevel internal 688 */ 689 protected boolean involvesTypeParameters_initialized = false; 690 /** 691 * @apilevel internal 692 */ 693 protected boolean involvesTypeParameters_value; 694 /** 695 * @attribute syn 696 * @aspect GenericMethodsInference 697 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericMethodsInference.jrag:16 698 */ 699 @SuppressWarnings({"unchecked", "cast"}) 700 public boolean involvesTypeParameters() { 701 if(involvesTypeParameters_computed) { 702 return involvesTypeParameters_value; 703 } 704 ASTNode$State state = state(); 705 if (!involvesTypeParameters_initialized) { 706 involvesTypeParameters_initialized = true; 707 involvesTypeParameters_value = false; 708 } 709 if (!state.IN_CIRCLE) { 710 state.IN_CIRCLE = true; 711 int num = state.boundariesCrossed; 712 boolean isFinal = this.is$Final(); 713 do { 714 involvesTypeParameters_visited = state.CIRCLE_INDEX; 715 state.CHANGE = false; 716 boolean new_involvesTypeParameters_value = involvesTypeParameters_compute(); 717 if (new_involvesTypeParameters_value!=involvesTypeParameters_value) 718 state.CHANGE = true; 719 involvesTypeParameters_value = new_involvesTypeParameters_value; 720 state.CIRCLE_INDEX++; 721 } while (state.CHANGE); 722 if(isFinal && num == state().boundariesCrossed) { 723 involvesTypeParameters_computed = true; 724 } 725 else { 726 state.RESET_CYCLE = true; 727 involvesTypeParameters_compute(); 728 state.RESET_CYCLE = false; 729 involvesTypeParameters_computed = false; 730 involvesTypeParameters_initialized = false; 731 } 732 state.IN_CIRCLE = false; 733 return involvesTypeParameters_value; 734 } 735 if(involvesTypeParameters_visited != state.CIRCLE_INDEX) { 736 involvesTypeParameters_visited = state.CIRCLE_INDEX; 737 if (state.RESET_CYCLE) { 738 involvesTypeParameters_computed = false; 739 involvesTypeParameters_initialized = false; 740 involvesTypeParameters_visited = -1; 741 return involvesTypeParameters_value; 742 } 743 boolean new_involvesTypeParameters_value = involvesTypeParameters_compute(); 744 if (new_involvesTypeParameters_value!=involvesTypeParameters_value) 745 state.CHANGE = true; 746 involvesTypeParameters_value = new_involvesTypeParameters_value; 747 return involvesTypeParameters_value; 748 } 749 return involvesTypeParameters_value; 750 } 751 /** 752 * @apilevel internal 753 */ 754 private boolean involvesTypeParameters_compute() { return true; } 755 /** 756 * @attribute syn 757 * @aspect GenericTypeVariables 758 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericTypeVariables.jrag:33 759 */ 760 public TypeDecl lowerBound() { 761 ASTNode$State state = state(); 762 try { return getTypeBound(0).type(); } 763 finally { 764 } 765 } 766 /** 767 * @attribute syn 768 * @aspect MemberMethods 769 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupMethod.jrag:210 770 */ 771 public Collection memberMethods(String name) { 772 ASTNode$State state = state(); 773 try { 774 Collection list = new HashSet(); 775 for(int i = 0; i < getNumTypeBound(); i++) { 776 for(Iterator iter = getTypeBound(i).type().memberMethods(name).iterator(); iter.hasNext(); ) { 777 MethodDecl decl = (MethodDecl)iter.next(); 778 //if(decl.accessibleFrom(hostType())) 779 list.add(decl); 780 } 781 } 782 return list; 783 } 784 finally { 785 } 786 } 787 protected java.util.Map memberFields_String_values; 788 /** 789 * @attribute syn 790 * @aspect GenericTypeVariablesMembers 791 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericTypeVariables.jrag:50 792 */ 793 @SuppressWarnings({"unchecked", "cast"}) 794 public SimpleSet memberFields(String name) { 795 Object _parameters = name; 796 if(memberFields_String_values == null) memberFields_String_values = new java.util.HashMap(4); 797 if(memberFields_String_values.containsKey(_parameters)) { 798 return (SimpleSet)memberFields_String_values.get(_parameters); 799 } 800 ASTNode$State state = state(); 801 int num = state.boundariesCrossed; 802 boolean isFinal = this.is$Final(); 803 SimpleSet memberFields_String_value = memberFields_compute(name); 804 if(isFinal && num == state().boundariesCrossed){ memberFields_String_values.put(_parameters, memberFields_String_value); } 805 return memberFields_String_value; 806 } 807 /** 808 * @apilevel internal 809 */ 810 private SimpleSet memberFields_compute(String name) { 811 SimpleSet set = SimpleSet.emptySet; 812 for(int i = 0; i < getNumTypeBound(); i++) { 813 for(Iterator iter = getTypeBound(i).type().memberFields(name).iterator(); iter.hasNext(); ) { 814 FieldDeclaration decl = (FieldDeclaration)iter.next(); 815 //if(decl.accessibleFrom(hostType())) 816 set = set.add(decl); 817 } 818 } 819 return set; 820 } 821 protected java.util.Map castingConversionTo_TypeDecl_values; 822 /** 823 * @attribute syn 824 * @aspect Generics 825 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:86 826 */ 827 @SuppressWarnings({"unchecked", "cast"}) 828 public boolean castingConversionTo(TypeDecl type) { 829 Object _parameters = type; 830 if(castingConversionTo_TypeDecl_values == null) castingConversionTo_TypeDecl_values = new java.util.HashMap(4); 831 if(castingConversionTo_TypeDecl_values.containsKey(_parameters)) { 832 return ((Boolean)castingConversionTo_TypeDecl_values.get(_parameters)).booleanValue(); 833 } 834 ASTNode$State state = state(); 835 int num = state.boundariesCrossed; 836 boolean isFinal = this.is$Final(); 837 boolean castingConversionTo_TypeDecl_value = castingConversionTo_compute(type); 838 if(isFinal && num == state().boundariesCrossed){ castingConversionTo_TypeDecl_values.put(_parameters, Boolean.valueOf(castingConversionTo_TypeDecl_value)); } 839 return castingConversionTo_TypeDecl_value; 840 } 841 /** 842 * @apilevel internal 843 */ 844 private boolean castingConversionTo_compute(TypeDecl type) { 845 if(!type.isReferenceType()) 846 return false; 847 if(getNumTypeBound() == 0) return true; 848 for(int i = 0; i < getNumTypeBound(); i++) 849 if(getTypeBound(i).type().castingConversionTo(type)) 850 return true; 851 return false; 852 } 853 /** 854 * @attribute syn 855 * @aspect Generics 856 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:148 857 */ 858 public boolean isNestedType() { 859 ASTNode$State state = state(); 860 try { return false; } 861 finally { 862 } 863 } 864 /** 865 * @apilevel internal 866 */ 867 protected boolean erasure_computed = false; 868 /** 869 * @apilevel internal 870 */ 871 protected TypeDecl erasure_value; 872 /** 873 * @attribute syn 874 * @aspect GenericsErasure 875 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:352 876 */ 877 @SuppressWarnings({"unchecked", "cast"}) 878 public TypeDecl erasure() { 879 if(erasure_computed) { 880 return erasure_value; 881 } 882 ASTNode$State state = state(); 883 int num = state.boundariesCrossed; 884 boolean isFinal = this.is$Final(); 885 erasure_value = erasure_compute(); 886 if(isFinal && num == state().boundariesCrossed){ erasure_computed = true; } 887 return erasure_value; 888 } 889 /** 890 * @apilevel internal 891 */ 892 private TypeDecl erasure_compute() { return getTypeBound(0).type().erasure(); } 893 /** 894 * @apilevel internal 895 */ 896 protected boolean fullName_computed = false; 897 /** 898 * @apilevel internal 899 */ 900 protected String fullName_value; 901 /** 902 * @attribute syn 903 * @aspect LookupParTypeDecl 904 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:563 905 */ 906 @SuppressWarnings({"unchecked", "cast"}) 907 public String fullName() { 908 if(fullName_computed) { 909 return fullName_value; 910 } 911 ASTNode$State state = state(); 912 int num = state.boundariesCrossed; 913 boolean isFinal = this.is$Final(); 914 fullName_value = fullName_compute(); 915 if(isFinal && num == state().boundariesCrossed){ fullName_computed = true; } 916 return fullName_value; 917 } 918 /** 919 * @apilevel internal 920 */ 921 private String fullName_compute() { 922 if(getParent().getParent() instanceof TypeDecl) { 923 TypeDecl typeDecl = (TypeDecl)getParent().getParent(); 924 return typeDecl.fullName() + "@" + name(); 925 } 926 return super.fullName(); 927 } 928 /** 929 * @attribute syn 930 * @aspect LookupParTypeDecl 931 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:571 932 */ 933 public boolean sameSignature(Access a) { 934 ASTNode$State state = state(); 935 try { return a.type() == this; } 936 finally { 937 } 938 } 939 /** 940 * @apilevel internal 941 */ 942 protected boolean lubType_computed = false; 943 /** 944 * @apilevel internal 945 */ 946 protected TypeDecl lubType_value; 947 /** 948 * @attribute syn 949 * @aspect LookupParTypeDecl 950 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:921 951 */ 952 @SuppressWarnings({"unchecked", "cast"}) 953 public TypeDecl lubType() { 954 if(lubType_computed) { 955 return lubType_value; 956 } 957 ASTNode$State state = state(); 958 int num = state.boundariesCrossed; 959 boolean isFinal = this.is$Final(); 960 lubType_value = lubType_compute(); 961 if(isFinal && num == state().boundariesCrossed){ lubType_computed = true; } 962 return lubType_value; 963 } 964 /** 965 * @apilevel internal 966 */ 967 private TypeDecl lubType_compute() { 968 ArrayList list = new ArrayList(); 969 for(int i = 0; i < getNumTypeBound(); i++) 970 list.add(getTypeBound(i).type()); 971 return lookupLUBType(list); 972 } 973 /** 974 * @apilevel internal 975 */ 976 protected int usesTypeVariable_visited = -1; 977 /** 978 * @apilevel internal 979 */ 980 protected boolean usesTypeVariable_computed = false; 981 /** 982 * @apilevel internal 983 */ 984 protected boolean usesTypeVariable_initialized = false; 985 /** 986 * @apilevel internal 987 */ 988 protected boolean usesTypeVariable_value; 989 /** 990 * @attribute syn 991 * @aspect LookupParTypeDecl 992 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:1079 993 */ 994 @SuppressWarnings({"unchecked", "cast"}) 995 public boolean usesTypeVariable() { 996 if(usesTypeVariable_computed) { 997 return usesTypeVariable_value; 998 } 999 ASTNode$State state = state(); 1000 if (!usesTypeVariable_initialized) { 1001 usesTypeVariable_initialized = true; 1002 usesTypeVariable_value = false; 1003 } 1004 if (!state.IN_CIRCLE) { 1005 state.IN_CIRCLE = true; 1006 int num = state.boundariesCrossed; 1007 boolean isFinal = this.is$Final(); 1008 do { 1009 usesTypeVariable_visited = state.CIRCLE_INDEX; 1010 state.CHANGE = false; 1011 boolean new_usesTypeVariable_value = usesTypeVariable_compute(); 1012 if (new_usesTypeVariable_value!=usesTypeVariable_value) 1013 state.CHANGE = true; 1014 usesTypeVariable_value = new_usesTypeVariable_value; 1015 state.CIRCLE_INDEX++; 1016 } while (state.CHANGE); 1017 if(isFinal && num == state().boundariesCrossed) { 1018 usesTypeVariable_computed = true; 1019 } 1020 else { 1021 state.RESET_CYCLE = true; 1022 usesTypeVariable_compute(); 1023 state.RESET_CYCLE = false; 1024 usesTypeVariable_computed = false; 1025 usesTypeVariable_initialized = false; 1026 } 1027 state.IN_CIRCLE = false; 1028 return usesTypeVariable_value; 1029 } 1030 if(usesTypeVariable_visited != state.CIRCLE_INDEX) { 1031 usesTypeVariable_visited = state.CIRCLE_INDEX; 1032 if (state.RESET_CYCLE) { 1033 usesTypeVariable_computed = false; 1034 usesTypeVariable_initialized = false; 1035 usesTypeVariable_visited = -1; 1036 return usesTypeVariable_value; 1037 } 1038 boolean new_usesTypeVariable_value = usesTypeVariable_compute(); 1039 if (new_usesTypeVariable_value!=usesTypeVariable_value) 1040 state.CHANGE = true; 1041 usesTypeVariable_value = new_usesTypeVariable_value; 1042 return usesTypeVariable_value; 1043 } 1044 return usesTypeVariable_value; 1045 } 1046 /** 1047 * @apilevel internal 1048 */ 1049 private boolean usesTypeVariable_compute() { return true; } 1050 protected java.util.Map accessibleFrom_TypeDecl_values; 1051 /** 1052 * @attribute syn 1053 * @aspect NewGenerics 1054 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:1499 1055 */ 1056 @SuppressWarnings({"unchecked", "cast"}) 1057 public boolean accessibleFrom(TypeDecl type) { 1058 Object _parameters = type; 1059 if(accessibleFrom_TypeDecl_values == null) accessibleFrom_TypeDecl_values = new java.util.HashMap(4); 1060 if(accessibleFrom_TypeDecl_values.containsKey(_parameters)) { 1061 return ((Boolean)accessibleFrom_TypeDecl_values.get(_parameters)).booleanValue(); 1062 } 1063 ASTNode$State state = state(); 1064 int num = state.boundariesCrossed; 1065 boolean isFinal = this.is$Final(); 1066 boolean accessibleFrom_TypeDecl_value = accessibleFrom_compute(type); 1067 if(isFinal && num == state().boundariesCrossed){ accessibleFrom_TypeDecl_values.put(_parameters, Boolean.valueOf(accessibleFrom_TypeDecl_value)); } 1068 return accessibleFrom_TypeDecl_value; 1069 } 1070 /** 1071 * @apilevel internal 1072 */ 1073 private boolean accessibleFrom_compute(TypeDecl type) { return true; } 1074 /** 1075 * @apilevel internal 1076 */ 1077 protected boolean typeName_computed = false; 1078 /** 1079 * @apilevel internal 1080 */ 1081 protected String typeName_value; 1082 /** 1083 * @attribute syn 1084 * @aspect NewGenerics 1085 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:1501 1086 */ 1087 @SuppressWarnings({"unchecked", "cast"}) 1088 public String typeName() { 1089 if(typeName_computed) { 1090 return typeName_value; 1091 } 1092 ASTNode$State state = state(); 1093 int num = state.boundariesCrossed; 1094 boolean isFinal = this.is$Final(); 1095 typeName_value = typeName_compute(); 1096 if(isFinal && num == state().boundariesCrossed){ typeName_computed = true; } 1097 return typeName_value; 1098 } 1099 /** 1100 * @apilevel internal 1101 */ 1102 private String typeName_compute() { return name(); } 1103 /** 1104 * @attribute syn 1105 * @aspect GenericsParTypeDecl 1106 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsParTypeDecl.jrag:73 1107 */ 1108 public boolean isTypeVariable() { 1109 ASTNode$State state = state(); 1110 try { return true; } 1111 finally { 1112 } 1113 } 1114 /** 1115 * @attribute syn 1116 * @aspect GenericsSubtype 1117 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:46 1118 */ 1119 public boolean supertypeWildcard(WildcardType type) { 1120 ASTNode$State state = state(); 1121 try { return true; } 1122 finally { 1123 } 1124 } 1125 /** 1126 * @attribute syn 1127 * @aspect GenericsSubtype 1128 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:57 1129 */ 1130 public boolean supertypeWildcardExtends(WildcardExtendsType type) { 1131 ASTNode$State state = state(); 1132 try { return type.extendsType().subtype(this); } 1133 finally { 1134 } 1135 } 1136 /** 1137 * @attribute syn 1138 * @aspect GenericsSubtype 1139 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:66 1140 */ 1141 public boolean supertypeWildcardSuper(WildcardSuperType type) { 1142 ASTNode$State state = state(); 1143 try { return type.superType().subtype(this); } 1144 finally { 1145 } 1146 } 1147 protected java.util.Map sameStructure_TypeDecl_values; 1148 /** 1149 * @attribute syn 1150 * @aspect GenericsSubtype 1151 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:215 1152 */ 1153 @SuppressWarnings({"unchecked", "cast"}) 1154 public boolean sameStructure(TypeDecl t) { 1155 Object _parameters = t; 1156 if(sameStructure_TypeDecl_values == null) sameStructure_TypeDecl_values = new java.util.HashMap(4); 1157 ASTNode$State.CircularValue _value; 1158 if(sameStructure_TypeDecl_values.containsKey(_parameters)) { 1159 Object _o = sameStructure_TypeDecl_values.get(_parameters); 1160 if(!(_o instanceof ASTNode$State.CircularValue)) { 1161 return ((Boolean)_o).booleanValue(); 1162 } 1163 else 1164 _value = (ASTNode$State.CircularValue)_o; 1165 } 1166 else { 1167 _value = new ASTNode$State.CircularValue(); 1168 sameStructure_TypeDecl_values.put(_parameters, _value); 1169 _value.value = Boolean.valueOf(true); 1170 } 1171 ASTNode$State state = state(); 1172 if (!state.IN_CIRCLE) { 1173 state.IN_CIRCLE = true; 1174 int num = state.boundariesCrossed; 1175 boolean isFinal = this.is$Final(); 1176 boolean new_sameStructure_TypeDecl_value; 1177 do { 1178 _value.visited = new Integer(state.CIRCLE_INDEX); 1179 state.CHANGE = false; 1180 new_sameStructure_TypeDecl_value = sameStructure_compute(t); 1181 if (new_sameStructure_TypeDecl_value!=((Boolean)_value.value).booleanValue()) { 1182 state.CHANGE = true; 1183 _value.value = Boolean.valueOf(new_sameStructure_TypeDecl_value); 1184 } 1185 state.CIRCLE_INDEX++; 1186 } while (state.CHANGE); 1187 if(isFinal && num == state().boundariesCrossed) { 1188 sameStructure_TypeDecl_values.put(_parameters, new_sameStructure_TypeDecl_value); 1189 } 1190 else { 1191 sameStructure_TypeDecl_values.remove(_parameters); 1192 state.RESET_CYCLE = true; 1193 sameStructure_compute(t); 1194 state.RESET_CYCLE = false; 1195 } 1196 state.IN_CIRCLE = false; 1197 return new_sameStructure_TypeDecl_value; 1198 } 1199 if(!new Integer(state.CIRCLE_INDEX).equals(_value.visited)) { 1200 _value.visited = new Integer(state.CIRCLE_INDEX); 1201 boolean new_sameStructure_TypeDecl_value = sameStructure_compute(t); 1202 if (state.RESET_CYCLE) { 1203 sameStructure_TypeDecl_values.remove(_parameters); 1204 } 1205 else if (new_sameStructure_TypeDecl_value!=((Boolean)_value.value).booleanValue()) { 1206 state.CHANGE = true; 1207 _value.value = new_sameStructure_TypeDecl_value; 1208 } 1209 return new_sameStructure_TypeDecl_value; 1210 } 1211 return ((Boolean)_value.value).booleanValue(); 1212 } 1213 /** 1214 * @apilevel internal 1215 */ 1216 private boolean sameStructure_compute(TypeDecl t) { 1217 if(!(t instanceof TypeVariable)) 1218 return false; 1219 if(t == this) 1220 return true; 1221 TypeVariable type = (TypeVariable)t; 1222 if(type.getNumTypeBound() != getNumTypeBound()) 1223 return false; 1224 for(int i = 0; i < getNumTypeBound(); i++) { 1225 boolean found = false; 1226 for(int j = i; !found && j < getNumTypeBound(); j++) 1227 if(getTypeBound(i).type().sameStructure(type.getTypeBound(j).type())) 1228 found = true; 1229 if(!found) 1230 return false; 1231 } 1232 return true; 1233 } 1234 /** 1235 * @attribute syn 1236 * @aspect GenericsSubtype 1237 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:450 1238 */ 1239 public boolean supertypeArrayDecl(ArrayDecl type) { 1240 ASTNode$State state = state(); 1241 try { 1242 for(int i = 0; i < getNumTypeBound(); i++) 1243 if(type.subtype(getTypeBound(i).type())) { 1244 return true; 1245 } 1246 return false; 1247 } 1248 finally { 1249 } 1250 } 1251 protected java.util.Map subtype_TypeDecl_values; 1252 /** 1253 * @attribute syn 1254 * @aspect GenericsSubtype 1255 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:290 1256 */ 1257 @SuppressWarnings({"unchecked", "cast"}) 1258 public boolean subtype(TypeDecl type) { 1259 Object _parameters = type; 1260 if(subtype_TypeDecl_values == null) subtype_TypeDecl_values = new java.util.HashMap(4); 1261 ASTNode$State.CircularValue _value; 1262 if(subtype_TypeDecl_values.containsKey(_parameters)) { 1263 Object _o = subtype_TypeDecl_values.get(_parameters); 1264 if(!(_o instanceof ASTNode$State.CircularValue)) { 1265 return ((Boolean)_o).booleanValue(); 1266 } 1267 else 1268 _value = (ASTNode$State.CircularValue)_o; 1269 } 1270 else { 1271 _value = new ASTNode$State.CircularValue(); 1272 subtype_TypeDecl_values.put(_parameters, _value); 1273 _value.value = Boolean.valueOf(true); 1274 } 1275 ASTNode$State state = state(); 1276 if (!state.IN_CIRCLE) { 1277 state.IN_CIRCLE = true; 1278 int num = state.boundariesCrossed; 1279 boolean isFinal = this.is$Final(); 1280 boolean new_subtype_TypeDecl_value; 1281 do { 1282 _value.visited = new Integer(state.CIRCLE_INDEX); 1283 state.CHANGE = false; 1284 new_subtype_TypeDecl_value = subtype_compute(type); 1285 if (new_subtype_TypeDecl_value!=((Boolean)_value.value).booleanValue()) { 1286 state.CHANGE = true; 1287 _value.value = Boolean.valueOf(new_subtype_TypeDecl_value); 1288 } 1289 state.CIRCLE_INDEX++; 1290 } while (state.CHANGE); 1291 if(isFinal && num == state().boundariesCrossed) { 1292 subtype_TypeDecl_values.put(_parameters, new_subtype_TypeDecl_value); 1293 } 1294 else { 1295 subtype_TypeDecl_values.remove(_parameters); 1296 state.RESET_CYCLE = true; 1297 subtype_compute(type); 1298 state.RESET_CYCLE = false; 1299 } 1300 state.IN_CIRCLE = false; 1301 return new_subtype_TypeDecl_value; 1302 } 1303 if(!new Integer(state.CIRCLE_INDEX).equals(_value.visited)) { 1304 _value.visited = new Integer(state.CIRCLE_INDEX); 1305 boolean new_subtype_TypeDecl_value = subtype_compute(type); 1306 if (state.RESET_CYCLE) { 1307 subtype_TypeDecl_values.remove(_parameters); 1308 } 1309 else if (new_subtype_TypeDecl_value!=((Boolean)_value.value).booleanValue()) { 1310 state.CHANGE = true; 1311 _value.value = new_subtype_TypeDecl_value; 1312 } 1313 return new_subtype_TypeDecl_value; 1314 } 1315 return ((Boolean)_value.value).booleanValue(); 1316 } 1317 /** 1318 * @apilevel internal 1319 */ 1320 private boolean subtype_compute(TypeDecl type) { return type.supertypeTypeVariable(this); } 1321 /** 1322 * @attribute syn 1323 * @aspect GenericsSubtype 1324 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:291 1325 */ 1326 public boolean supertypeTypeVariable(TypeVariable type) { 1327 ASTNode$State state = state(); 1328 try { 1329 if(type == this) 1330 return true; 1331 for(int i = 0; i < getNumTypeBound(); i++) { 1332 boolean found = false; 1333 for(int j = 0; !found && j < type.getNumTypeBound(); j++) { 1334 if(type.getSubstitutedTypeBound(j, this).type().subtype(getTypeBound(i).type())) 1335 found = true; 1336 } 1337 if(!found) 1338 return false; 1339 } 1340 return true; 1341 } 1342 finally { 1343 } 1344 } 1345 protected java.util.Map getSubstitutedTypeBound_int_TypeDecl_values; 1346 /** 1347 * @attribute syn 1348 * @aspect GenericsSubtype 1349 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:314 1350 */ 1351 @SuppressWarnings({"unchecked", "cast"}) 1352 public Access getSubstitutedTypeBound(int i, TypeDecl type) { 1353 java.util.List _parameters = new java.util.ArrayList(2); 1354 _parameters.add(Integer.valueOf(i)); 1355 _parameters.add(type); 1356 if(getSubstitutedTypeBound_int_TypeDecl_values == null) getSubstitutedTypeBound_int_TypeDecl_values = new java.util.HashMap(4); 1357 if(getSubstitutedTypeBound_int_TypeDecl_values.containsKey(_parameters)) { 1358 return (Access)getSubstitutedTypeBound_int_TypeDecl_values.get(_parameters); 1359 } 1360 ASTNode$State state = state(); 1361 int num = state.boundariesCrossed; 1362 boolean isFinal = this.is$Final(); 1363 Access getSubstitutedTypeBound_int_TypeDecl_value = getSubstitutedTypeBound_compute(i, type); 1364 if(isFinal && num == state().boundariesCrossed){ getSubstitutedTypeBound_int_TypeDecl_values.put(_parameters, getSubstitutedTypeBound_int_TypeDecl_value); } 1365 return getSubstitutedTypeBound_int_TypeDecl_value; 1366 } 1367 /** 1368 * @apilevel internal 1369 */ 1370 private Access getSubstitutedTypeBound_compute(int i, TypeDecl type) { 1371 Access bound = getTypeBound(i); 1372 if(!bound.type().usesTypeVariable()) 1373 return bound; 1374 final TypeDecl typeDecl = type; 1375 Access access = bound.type().substitute( 1376 new Parameterization() { 1377 public boolean isRawType() { 1378 return false; 1379 } 1380 public TypeDecl substitute(TypeVariable typeVariable) { 1381 return typeVariable == TypeVariable.this ? typeDecl : typeVariable; 1382 } 1383 } 1384 ); 1385 access.setParent(this); 1386 return access; 1387 } 1388 /** 1389 * @attribute syn 1390 * @aspect GenericsSubtype 1391 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:421 1392 */ 1393 public boolean supertypeClassDecl(ClassDecl type) { 1394 ASTNode$State state = state(); 1395 try { 1396 for(int i = 0; i < getNumTypeBound(); i++) 1397 if(!type.subtype(getSubstitutedTypeBound(i, type).type())) 1398 return false; 1399 return true; 1400 } 1401 finally { 1402 } 1403 } 1404 /** 1405 * @attribute syn 1406 * @aspect GenericsSubtype 1407 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:437 1408 */ 1409 public boolean supertypeInterfaceDecl(InterfaceDecl type) { 1410 ASTNode$State state = state(); 1411 try { 1412 for(int i = 0; i < getNumTypeBound(); i++) 1413 if(!type.subtype(getSubstitutedTypeBound(i, type).type())) 1414 return false; 1415 return true; 1416 } 1417 finally { 1418 } 1419 } 1420 protected java.util.Map instanceOf_TypeDecl_values; 1421 /** 1422 * @attribute syn 1423 * @aspect GenericsSubtype 1424 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:400 1425 */ 1426 @SuppressWarnings({"unchecked", "cast"}) 1427 public boolean instanceOf(TypeDecl type) { 1428 Object _parameters = type; 1429 if(instanceOf_TypeDecl_values == null) instanceOf_TypeDecl_values = new java.util.HashMap(4); 1430 if(instanceOf_TypeDecl_values.containsKey(_parameters)) { 1431 return ((Boolean)instanceOf_TypeDecl_values.get(_parameters)).booleanValue(); 1432 } 1433 ASTNode$State state = state(); 1434 int num = state.boundariesCrossed; 1435 boolean isFinal = this.is$Final(); 1436 boolean instanceOf_TypeDecl_value = instanceOf_compute(type); 1437 if(isFinal && num == state().boundariesCrossed){ instanceOf_TypeDecl_values.put(_parameters, Boolean.valueOf(instanceOf_TypeDecl_value)); } 1438 return instanceOf_TypeDecl_value; 1439 } 1440 /** 1441 * @apilevel internal 1442 */ 1443 private boolean instanceOf_compute(TypeDecl type) { return subtype(type); } 1444 /** 1445 * @apilevel internal 1446 */ 1447 protected boolean typeDescriptor_computed = false; 1448 /** 1449 * @apilevel internal 1450 */ 1451 protected String typeDescriptor_value; 1452 /** 1453 * @attribute syn 1454 * @aspect GenericsCodegen 1455 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/GenericsCodegen.jrag:15 1456 */ 1457 @SuppressWarnings({"unchecked", "cast"}) 1458 public String typeDescriptor() { 1459 if(typeDescriptor_computed) { 1460 return typeDescriptor_value; 1461 } 1462 ASTNode$State state = state(); 1463 int num = state.boundariesCrossed; 1464 boolean isFinal = this.is$Final(); 1465 typeDescriptor_value = typeDescriptor_compute(); 1466 if(isFinal && num == state().boundariesCrossed){ typeDescriptor_computed = true; } 1467 return typeDescriptor_value; 1468 } 1469 /** 1470 * @apilevel internal 1471 */ 1472 private String typeDescriptor_compute() { return erasure().typeDescriptor(); } 1473 /** 1474 * @attribute syn 1475 * @aspect CreateBCode 1476 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CreateBCode.jrag:820 1477 */ 1478 public String arrayTypeDescriptor() { 1479 ASTNode$State state = state(); 1480 try { return erasure().arrayTypeDescriptor(); } 1481 finally { 1482 } 1483 } 1484 /** 1485 * @apilevel internal 1486 */ 1487 protected boolean constantPoolName_computed = false; 1488 /** 1489 * @apilevel internal 1490 */ 1491 protected String constantPoolName_value; 1492 /** 1493 * @attribute syn 1494 * @aspect GenericsCodegen 1495 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/GenericsCodegen.jrag:172 1496 */ 1497 @SuppressWarnings({"unchecked", "cast"}) 1498 public String constantPoolName() { 1499 if(constantPoolName_computed) { 1500 return constantPoolName_value; 1501 } 1502 ASTNode$State state = state(); 1503 int num = state.boundariesCrossed; 1504 boolean isFinal = this.is$Final(); 1505 constantPoolName_value = constantPoolName_compute(); 1506 if(isFinal && num == state().boundariesCrossed){ constantPoolName_computed = true; } 1507 return constantPoolName_value; 1508 } 1509 /** 1510 * @apilevel internal 1511 */ 1512 private String constantPoolName_compute() { return erasure().constantPoolName(); } 1513 /** 1514 * @apilevel internal 1515 */ 1516 protected boolean needsSignatureAttribute_computed = false; 1517 /** 1518 * @apilevel internal 1519 */ 1520 protected boolean needsSignatureAttribute_value; 1521 /** 1522 * @attribute syn 1523 * @aspect GenericsCodegen 1524 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/GenericsCodegen.jrag:345 1525 */ 1526 @SuppressWarnings({"unchecked", "cast"}) 1527 public boolean needsSignatureAttribute() { 1528 if(needsSignatureAttribute_computed) { 1529 return needsSignatureAttribute_value; 1530 } 1531 ASTNode$State state = state(); 1532 int num = state.boundariesCrossed; 1533 boolean isFinal = this.is$Final(); 1534 needsSignatureAttribute_value = needsSignatureAttribute_compute(); 1535 if(isFinal && num == state().boundariesCrossed){ needsSignatureAttribute_computed = true; } 1536 return needsSignatureAttribute_value; 1537 } 1538 /** 1539 * @apilevel internal 1540 */ 1541 private boolean needsSignatureAttribute_compute() { return true; } 1542 /** 1543 * @attribute syn 1544 * @aspect GenericsCodegen 1545 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/GenericsCodegen.jrag:426 1546 */ 1547 public String formalTypeParameter() { 1548 ASTNode$State state = state(); 1549 try { 1550 StringBuffer buf = new StringBuffer(); 1551 // Identifier 1552 buf.append(name()); 1553 buf.append(":"); 1554 if(getNumTypeBound() > 0) { 1555 // ClassBound InterfaceBound* 1556 if(getTypeBound(0).type().isClassDecl()) 1557 buf.append(getTypeBound(0).type().fieldTypeSignature()); 1558 else 1559 buf.append(":" + getTypeBound(0).type().fieldTypeSignature()); 1560 for(int i = 1; i < getNumTypeBound(); i++) 1561 buf.append(":" + getTypeBound(i).type().fieldTypeSignature()); 1562 } 1563 return buf.toString(); 1564 } 1565 finally { 1566 } 1567 } 1568 /** 1569 * @apilevel internal 1570 */ 1571 protected boolean fieldTypeSignature_computed = false; 1572 /** 1573 * @apilevel internal 1574 */ 1575 protected String fieldTypeSignature_value; 1576 /** 1577 * @attribute syn 1578 * @aspect GenericsCodegen 1579 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/GenericsCodegen.jrag:445 1580 */ 1581 @SuppressWarnings({"unchecked", "cast"}) 1582 public String fieldTypeSignature() { 1583 if(fieldTypeSignature_computed) { 1584 return fieldTypeSignature_value; 1585 } 1586 ASTNode$State state = state(); 1587 int num = state.boundariesCrossed; 1588 boolean isFinal = this.is$Final(); 1589 fieldTypeSignature_value = fieldTypeSignature_compute(); 1590 if(isFinal && num == state().boundariesCrossed){ fieldTypeSignature_computed = true; } 1591 return fieldTypeSignature_value; 1592 } 1593 /** 1594 * @apilevel internal 1595 */ 1596 private String fieldTypeSignature_compute() { return classTypeSignature(); } 1597 /** 1598 * @apilevel internal 1599 */ 1600 protected boolean classTypeSignature_computed = false; 1601 /** 1602 * @apilevel internal 1603 */ 1604 protected String classTypeSignature_value; 1605 /** 1606 * @attribute syn 1607 * @aspect GenericsCodegen 1608 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/GenericsCodegen.jrag:454 1609 */ 1610 @SuppressWarnings({"unchecked", "cast"}) 1611 public String classTypeSignature() { 1612 if(classTypeSignature_computed) { 1613 return classTypeSignature_value; 1614 } 1615 ASTNode$State state = state(); 1616 int num = state.boundariesCrossed; 1617 boolean isFinal = this.is$Final(); 1618 classTypeSignature_value = classTypeSignature_compute(); 1619 if(isFinal && num == state().boundariesCrossed){ classTypeSignature_computed = true; } 1620 return classTypeSignature_value; 1621 } 1622 /** 1623 * @apilevel internal 1624 */ 1625 private String classTypeSignature_compute() { return "T" + name() + ";"; } 1626 /** 1627 * @apilevel internal 1628 */ 1629 protected boolean classBound_computed = false; 1630 /** 1631 * @apilevel internal 1632 */ 1633 protected String classBound_value; 1634 /** 1635 * @attribute syn 1636 * @aspect GenericsCodegen 1637 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/GenericsCodegen.jrag:504 1638 */ 1639 @SuppressWarnings({"unchecked", "cast"}) 1640 public String classBound() { 1641 if(classBound_computed) { 1642 return classBound_value; 1643 } 1644 ASTNode$State state = state(); 1645 int num = state.boundariesCrossed; 1646 boolean isFinal = this.is$Final(); 1647 classBound_value = classBound_compute(); 1648 if(isFinal && num == state().boundariesCrossed){ classBound_computed = true; } 1649 return classBound_value; 1650 } 1651 /** 1652 * @apilevel internal 1653 */ 1654 private String classBound_compute() { 1655 if (getNumTypeBound() > 0) { 1656 return getTypeBound(0).type().fieldTypeSignature(); 1657 } 1658 return ""; 1659 } 1660 /** 1661 * @apilevel internal 1662 */ 1663 protected boolean interfaceBounds_computed = false; 1664 /** 1665 * @apilevel internal 1666 */ 1667 protected String interfaceBounds_value; 1668 /** 1669 * @attribute syn 1670 * @aspect GenericsCodegen 1671 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/GenericsCodegen.jrag:510 1672 */ 1673 @SuppressWarnings({"unchecked", "cast"}) 1674 public String interfaceBounds() { 1675 if(interfaceBounds_computed) { 1676 return interfaceBounds_value; 1677 } 1678 ASTNode$State state = state(); 1679 int num = state.boundariesCrossed; 1680 boolean isFinal = this.is$Final(); 1681 interfaceBounds_value = interfaceBounds_compute(); 1682 if(isFinal && num == state().boundariesCrossed){ interfaceBounds_computed = true; } 1683 return interfaceBounds_value; 1684 } 1685 /** 1686 * @apilevel internal 1687 */ 1688 private String interfaceBounds_compute() { 1689 StringBuffer buf = new StringBuffer(); 1690 for (int i = 1; i < getNumTypeBound(); ++i) { 1691 buf.append(":"); 1692 buf.append(getTypeBound(i).type().fieldTypeSignature()); 1693 } 1694 return buf.toString(); 1695 } 1696 /** 1697 * A type is reifiable if it either refers to a non-parameterized type, 1698 * is a raw type, is a parameterized type with only unbound wildcard 1699 * parameters or is an array type with a reifiable type parameter. 1700 * 1701 * @see "JLSv3 §4.7" 1702 * @attribute syn 1703 * @aspect SafeVarargs 1704 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/SafeVarargs.jrag:106 1705 */ 1706 public boolean isReifiable() { 1707 ASTNode$State state = state(); 1708 try { return false; } 1709 finally { 1710 } 1711 } 1712 /** 1713 * @attribute inh 1714 * @aspect LookupParTypeDecl 1715 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:919 1716 */ 1717 @SuppressWarnings({"unchecked", "cast"}) 1718 public TypeDecl typeObject() { 1719 ASTNode$State state = state(); 1720 TypeDecl typeObject_value = getParent().Define_TypeDecl_typeObject(this, null); 1721 return typeObject_value; 1722 } 1723 /** 1724 * @attribute inh 1725 * @aspect LookupParTypeDecl 1726 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:961 1727 */ 1728 @SuppressWarnings({"unchecked", "cast"}) 1729 public TypeDecl typeNull() { 1730 ASTNode$State state = state(); 1731 TypeDecl typeNull_value = getParent().Define_TypeDecl_typeNull(this, null); 1732 return typeNull_value; 1733 } 1734 /** 1735 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericTypeVariables.jrag:13 1736 * @apilevel internal 1737 */ 1738 public NameType Define_NameType_nameType(ASTNode caller, ASTNode child) { 1739 if(caller == getTypeBoundListNoTransform()) { 1740 int childIndex = caller.getIndexOfChild(child); 1741 return NameType.TYPE_NAME; 1742 } 1743 else { return super.Define_NameType_nameType(caller, child); 1744 } 1745 } 1746 /** 1747 * @apilevel internal 1748 */ 1749 public ASTNode rewriteTo() { 1750 // Declared in /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericTypeVariables.jrag at line 16 1751 if(getNumTypeBound() == 0) { 1752 state().duringGenericTypeVariables++; 1753 ASTNode result = rewriteRule0(); 1754 state().duringGenericTypeVariables--; 1755 return result; 1756 } 1757 1758 return super.rewriteTo(); 1759 } 1760 /** 1761 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericTypeVariables.jrag:16 1762 * @apilevel internal 1763 */ private TypeVariable rewriteRule0() { 1764 { 1765 addTypeBound( 1766 new TypeAccess( 1767 "java.lang", 1768 "Object" 1769 ) 1770 ); 1771 return this; 1772 } } 1773 }