001 /* This file was generated with JastAdd2 (http://jastadd.org) version 2.1.13-12-g880e696 */ 002 package org.extendj.ast; 003 004 import java.util.HashSet; 005 import java.io.File; 006 import java.util.Set; 007 import java.util.Collections; 008 import java.util.Collection; 009 import java.util.ArrayList; 010 import beaver.*; 011 import java.util.*; 012 import java.io.ByteArrayOutputStream; 013 import java.io.PrintStream; 014 import java.lang.reflect.InvocationTargetException; 015 import java.lang.reflect.Method; 016 import org.jastadd.util.*; 017 import java.util.zip.*; 018 import java.io.*; 019 import org.jastadd.util.PrettyPrintable; 020 import org.jastadd.util.PrettyPrinter; 021 import java.io.FileNotFoundException; 022 import java.io.BufferedInputStream; 023 import java.io.DataInputStream; 024 /** 025 * @ast node 026 * @declaredat /home/jesper/git/extendj/java5/grammar/Generics.ast:18 027 * @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>; 028 029 */ 030 public class TypeVariable extends ReferenceType implements Cloneable { 031 /** 032 * @aspect GenericTypeVariables 033 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericTypeVariables.jrag:49 034 */ 035 public void nameCheck() { 036 if (extractSingleType(lookupType(name())) != this) { 037 errorf("*** Semantic Error: type variable %s is multiply declared", name()); 038 } 039 } 040 /** 041 * @aspect GenricTypeVariablesTypeAnalysis 042 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericTypeVariables.jrag:86 043 */ 044 public void typeCheck() { 045 if (!getTypeBound(0).type().isTypeVariable() && !getTypeBound(0).type().isClassDecl() 046 && !getTypeBound(0).type().isInterfaceDecl()) { 047 errorf("the first type bound must be either a type variable," 048 + " or a class or interface type which %s is not", 049 getTypeBound(0).type().fullName()); 050 } 051 for (int i = 1; i < getNumTypeBound(); i++) { 052 if (!getTypeBound(i).type().isInterfaceDecl()) { 053 errorf("type bound %s must be an interface type which %s is not", 054 i, getTypeBound(i).type().fullName()); 055 } 056 } 057 HashSet typeSet = new HashSet(); 058 for (int i = 0; i < getNumTypeBound(); i++) { 059 TypeDecl type = getTypeBound(i).type(); 060 TypeDecl erasure = type.erasure(); 061 if (typeSet.contains(erasure)) { 062 if (type != erasure) { 063 errorf("the erasure %s of typebound %s is multiply declared in %s", 064 erasure.fullName(), getTypeBound(i).prettyPrint(), this); 065 } else { 066 errorf("%s is multiply declared", type.fullName()); 067 } 068 } 069 typeSet.add(erasure); 070 } 071 072 for (int i = 0; i < getNumTypeBound(); i++) { 073 TypeDecl type = getTypeBound(i).type(); 074 for (Iterator iter = type.methodsIterator(); iter.hasNext(); ) { 075 MethodDecl m = (MethodDecl) iter.next(); 076 for (int j = i+1; j < getNumTypeBound(); j++) { 077 TypeDecl destType = getTypeBound(j).type(); 078 for (Iterator destIter = destType.memberMethods(m.name()).iterator(); destIter.hasNext(); ) { 079 MethodDecl n = (MethodDecl) destIter.next(); 080 if (m.sameSignature(n) && m.type() != n.type()) { 081 errorf("the two bounds, %s and %s, in type variable %s have" 082 + " a method %s with conflicting return types %s and %s", 083 type.name(), destType.name(), name(), m.signature(), 084 m.type().name(), n.type().name()); 085 } 086 } 087 } 088 } 089 } 090 091 092 } 093 /** 094 * @aspect LookupParTypeDecl 095 * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:1039 096 */ 097 public Access substitute(Parameterization parTypeDecl) { 098 if (parTypeDecl.isRawType()) { 099 return erasure().createBoundAccess(); 100 } 101 return parTypeDecl.substitute(this).createBoundAccess(); 102 } 103 /** 104 * @aspect LookupParTypeDecl 105 * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:1102 106 */ 107 public Access substituteReturnType(Parameterization parTypeDecl) { 108 if (parTypeDecl.isRawType()) { 109 return erasure().createBoundAccess(); 110 } 111 TypeDecl typeDecl = parTypeDecl.substitute(this); 112 if (typeDecl instanceof WildcardType) { 113 // The bound of this type variable 114 return createBoundAccess(); 115 //return lubType().createBoundAccess(); 116 //return typeObject().createBoundAccess(); 117 } else if (typeDecl instanceof WildcardExtendsType) { 118 if (typeDecl.instanceOf(this)) { 119 return ((WildcardExtendsType) typeDecl).extendsType().createBoundAccess(); 120 } else { 121 return createBoundAccess(); 122 } 123 124 // the bound of this type variable of the bound of the wild card if it is more specific 125 //return ((WildcardExtendsType) typeDecl).extendsType().createBoundAccess(); 126 } else if (typeDecl instanceof WildcardSuperType) { 127 // the bound of this type variable 128 return createBoundAccess(); 129 //return typeObject().createBoundAccess(); 130 } 131 return typeDecl.createBoundAccess(); 132 } 133 /** 134 * @aspect LookupParTypeDecl 135 * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:1142 136 */ 137 public Access substituteParameterType(Parameterization parTypeDecl) { 138 if (parTypeDecl.isRawType()) { 139 return erasure().createBoundAccess(); 140 } 141 TypeDecl typeDecl = parTypeDecl.substitute(this); 142 if (typeDecl instanceof WildcardType) { 143 return typeNull().createQualifiedAccess(); 144 } else if (typeDecl instanceof WildcardExtendsType) { 145 return typeNull().createQualifiedAccess(); 146 } else if (typeDecl instanceof WildcardSuperType) { 147 return ((WildcardSuperType) typeDecl).superType().createBoundAccess(); 148 } 149 return typeDecl.createBoundAccess(); 150 } 151 /** 152 * @aspect NewGenerics 153 * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:1608 154 */ 155 public Access createQualifiedAccess() { 156 return createBoundAccess(); 157 } 158 /** 159 * @aspect Java5PrettyPrint 160 * @declaredat /home/jesper/git/extendj/java5/frontend/PrettyPrint.jadd:280 161 */ 162 public void prettyPrint(PrettyPrinter out) { 163 out.print(getID()); 164 if (hasTypeBound()) { 165 out.print(" extends "); 166 out.join(getTypeBoundList(), new PrettyPrinter.Joiner() { 167 @Override 168 public void printSeparator(PrettyPrinter out) { 169 out.print(" & "); 170 } 171 }); 172 } 173 } 174 /** 175 * @declaredat ASTNode:1 176 */ 177 public TypeVariable() { 178 super(); 179 } 180 /** 181 * Initializes the child array to the correct size. 182 * Initializes List and Opt nta children. 183 * @apilevel internal 184 * @ast method 185 * @declaredat ASTNode:10 186 */ 187 public void init$Children() { 188 children = new ASTNode[3]; 189 setChild(new List(), 1); 190 setChild(new List(), 2); 191 } 192 /** 193 * @declaredat ASTNode:15 194 */ 195 public TypeVariable(Modifiers p0, String p1, List<BodyDecl> p2, List<Access> p3) { 196 setChild(p0, 0); 197 setID(p1); 198 setChild(p2, 1); 199 setChild(p3, 2); 200 } 201 /** 202 * @declaredat ASTNode:21 203 */ 204 public TypeVariable(Modifiers p0, beaver.Symbol p1, List<BodyDecl> p2, List<Access> p3) { 205 setChild(p0, 0); 206 setID(p1); 207 setChild(p2, 1); 208 setChild(p3, 2); 209 } 210 /** 211 * @apilevel low-level 212 * @declaredat ASTNode:30 213 */ 214 protected int numChildren() { 215 return 3; 216 } 217 /** 218 * @apilevel internal 219 * @declaredat ASTNode:36 220 */ 221 public boolean mayHaveRewrite() { 222 return true; 223 } 224 /** 225 * @apilevel internal 226 * @declaredat ASTNode:42 227 */ 228 public void flushAttrCache() { 229 super.flushAttrCache(); 230 unboxed_reset(); 231 toInterface_reset(); 232 involvesTypeParameters_reset(); 233 memberFields_String_reset(); 234 castingConversionTo_TypeDecl_reset(); 235 erasure_reset(); 236 fullName_reset(); 237 lubType_reset(); 238 usesTypeVariable_reset(); 239 accessibleFrom_TypeDecl_reset(); 240 typeName_reset(); 241 sameStructure_TypeDecl_reset(); 242 subtype_TypeDecl_reset(); 243 getSubstitutedTypeBound_int_TypeDecl_reset(); 244 instanceOf_TypeDecl_reset(); 245 typeDescriptor_reset(); 246 constantPoolName_reset(); 247 needsSignatureAttribute_reset(); 248 fieldTypeSignature_reset(); 249 classTypeSignature_reset(); 250 classBound_reset(); 251 interfaceBounds_reset(); 252 strictSubtype_TypeDecl_reset(); 253 typeVarPosition_reset(); 254 genericMethodLevel_reset(); 255 typeVarInMethod_reset(); 256 } 257 /** 258 * @apilevel internal 259 * @declaredat ASTNode:74 260 */ 261 public void flushCollectionCache() { 262 super.flushCollectionCache(); 263 } 264 /** 265 * @apilevel internal 266 * @declaredat ASTNode:80 267 */ 268 public void flushRewriteCache() { 269 super.flushRewriteCache(); 270 } 271 /** 272 * @apilevel internal 273 * @declaredat ASTNode:86 274 */ 275 public TypeVariable clone() throws CloneNotSupportedException { 276 TypeVariable node = (TypeVariable) super.clone(); 277 return node; 278 } 279 /** 280 * @apilevel internal 281 * @declaredat ASTNode:93 282 */ 283 public TypeVariable copy() { 284 try { 285 TypeVariable node = (TypeVariable) clone(); 286 node.parent = null; 287 if (children != null) { 288 node.children = (ASTNode[]) children.clone(); 289 } 290 return node; 291 } catch (CloneNotSupportedException e) { 292 throw new Error("Error: clone not supported for " + getClass().getName()); 293 } 294 } 295 /** 296 * Create a deep copy of the AST subtree at this node. 297 * The copy is dangling, i.e. has no parent. 298 * @return dangling copy of the subtree at this node 299 * @apilevel low-level 300 * @deprecated Please use treeCopy or treeCopyNoTransform instead 301 * @declaredat ASTNode:112 302 */ 303 @Deprecated 304 public TypeVariable fullCopy() { 305 return treeCopyNoTransform(); 306 } 307 /** 308 * Create a deep copy of the AST subtree at this node. 309 * The copy is dangling, i.e. has no parent. 310 * @return dangling copy of the subtree at this node 311 * @apilevel low-level 312 * @declaredat ASTNode:122 313 */ 314 public TypeVariable treeCopyNoTransform() { 315 TypeVariable tree = (TypeVariable) copy(); 316 if (children != null) { 317 for (int i = 0; i < children.length; ++i) { 318 ASTNode child = (ASTNode) children[i]; 319 if (child != null) { 320 child = child.treeCopyNoTransform(); 321 tree.setChild(child, i); 322 } 323 } 324 } 325 return tree; 326 } 327 /** 328 * Create a deep copy of the AST subtree at this node. 329 * The subtree of this node is traversed to trigger rewrites before copy. 330 * The copy is dangling, i.e. has no parent. 331 * @return dangling copy of the subtree at this node 332 * @apilevel low-level 333 * @declaredat ASTNode:142 334 */ 335 public TypeVariable treeCopy() { 336 doFullTraversal(); 337 return treeCopyNoTransform(); 338 } 339 /** 340 * @apilevel internal 341 * @declaredat ASTNode:149 342 */ 343 protected boolean is$Equal(ASTNode node) { 344 return super.is$Equal(node) && (tokenString_ID == ((TypeVariable)node).tokenString_ID); 345 } 346 /** 347 * Replaces the Modifiers child. 348 * @param node The new node to replace the Modifiers child. 349 * @apilevel high-level 350 */ 351 public void setModifiers(Modifiers node) { 352 setChild(node, 0); 353 } 354 /** 355 * Retrieves the Modifiers child. 356 * @return The current node used as the Modifiers child. 357 * @apilevel high-level 358 */ 359 @ASTNodeAnnotation.Child(name="Modifiers") 360 public Modifiers getModifiers() { 361 return (Modifiers) getChild(0); 362 } 363 /** 364 * Retrieves the Modifiers child. 365 * <p><em>This method does not invoke AST transformations.</em></p> 366 * @return The current node used as the Modifiers child. 367 * @apilevel low-level 368 */ 369 public Modifiers getModifiersNoTransform() { 370 return (Modifiers) getChildNoTransform(0); 371 } 372 /** 373 * Replaces the lexeme ID. 374 * @param value The new value for the lexeme ID. 375 * @apilevel high-level 376 */ 377 public void setID(String value) { 378 tokenString_ID = value; 379 } 380 /** 381 * JastAdd-internal setter for lexeme ID using the Beaver parser. 382 * @param symbol Symbol containing the new value for the lexeme ID 383 * @apilevel internal 384 */ 385 public void setID(beaver.Symbol symbol) { 386 if (symbol.value != null && !(symbol.value instanceof String)) 387 throw new UnsupportedOperationException("setID is only valid for String lexemes"); 388 tokenString_ID = (String)symbol.value; 389 IDstart = symbol.getStart(); 390 IDend = symbol.getEnd(); 391 } 392 /** 393 * Retrieves the value for the lexeme ID. 394 * @return The value for the lexeme ID. 395 * @apilevel high-level 396 */ 397 @ASTNodeAnnotation.Token(name="ID") 398 public String getID() { 399 return tokenString_ID != null ? tokenString_ID : ""; 400 } 401 /** 402 * Replaces the BodyDecl list. 403 * @param list The new list node to be used as the BodyDecl list. 404 * @apilevel high-level 405 */ 406 public void setBodyDeclList(List<BodyDecl> list) { 407 setChild(list, 1); 408 } 409 /** 410 * Retrieves the number of children in the BodyDecl list. 411 * @return Number of children in the BodyDecl list. 412 * @apilevel high-level 413 */ 414 public int getNumBodyDecl() { 415 return getBodyDeclList().getNumChild(); 416 } 417 /** 418 * Retrieves the number of children in the BodyDecl list. 419 * Calling this method will not trigger rewrites. 420 * @return Number of children in the BodyDecl list. 421 * @apilevel low-level 422 */ 423 public int getNumBodyDeclNoTransform() { 424 return getBodyDeclListNoTransform().getNumChildNoTransform(); 425 } 426 /** 427 * Retrieves the element at index {@code i} in the BodyDecl list. 428 * @param i Index of the element to return. 429 * @return The element at position {@code i} in the BodyDecl list. 430 * @apilevel high-level 431 */ 432 public BodyDecl getBodyDecl(int i) { 433 return (BodyDecl) getBodyDeclList().getChild(i); 434 } 435 /** 436 * Check whether the BodyDecl list has any children. 437 * @return {@code true} if it has at least one child, {@code false} otherwise. 438 * @apilevel high-level 439 */ 440 public boolean hasBodyDecl() { 441 return getBodyDeclList().getNumChild() != 0; 442 } 443 /** 444 * Append an element to the BodyDecl list. 445 * @param node The element to append to the BodyDecl list. 446 * @apilevel high-level 447 */ 448 public void addBodyDecl(BodyDecl node) { 449 List<BodyDecl> list = (parent == null) ? getBodyDeclListNoTransform() : getBodyDeclList(); 450 list.addChild(node); 451 } 452 /** 453 * @apilevel low-level 454 */ 455 public void addBodyDeclNoTransform(BodyDecl node) { 456 List<BodyDecl> list = getBodyDeclListNoTransform(); 457 list.addChild(node); 458 } 459 /** 460 * Replaces the BodyDecl list element at index {@code i} with the new node {@code node}. 461 * @param node The new node to replace the old list element. 462 * @param i The list index of the node to be replaced. 463 * @apilevel high-level 464 */ 465 public void setBodyDecl(BodyDecl node, int i) { 466 List<BodyDecl> list = getBodyDeclList(); 467 list.setChild(node, i); 468 } 469 /** 470 * Retrieves the BodyDecl list. 471 * @return The node representing the BodyDecl list. 472 * @apilevel high-level 473 */ 474 @ASTNodeAnnotation.ListChild(name="BodyDecl") 475 public List<BodyDecl> getBodyDeclList() { 476 List<BodyDecl> list = (List<BodyDecl>) getChild(1); 477 return list; 478 } 479 /** 480 * Retrieves the BodyDecl list. 481 * <p><em>This method does not invoke AST transformations.</em></p> 482 * @return The node representing the BodyDecl list. 483 * @apilevel low-level 484 */ 485 public List<BodyDecl> getBodyDeclListNoTransform() { 486 return (List<BodyDecl>) getChildNoTransform(1); 487 } 488 /** 489 * Retrieves the BodyDecl list. 490 * @return The node representing the BodyDecl list. 491 * @apilevel high-level 492 */ 493 public List<BodyDecl> getBodyDecls() { 494 return getBodyDeclList(); 495 } 496 /** 497 * Retrieves the BodyDecl list. 498 * <p><em>This method does not invoke AST transformations.</em></p> 499 * @return The node representing the BodyDecl list. 500 * @apilevel low-level 501 */ 502 public List<BodyDecl> getBodyDeclsNoTransform() { 503 return getBodyDeclListNoTransform(); 504 } 505 /** 506 * Replaces the TypeBound list. 507 * @param list The new list node to be used as the TypeBound list. 508 * @apilevel high-level 509 */ 510 public void setTypeBoundList(List<Access> list) { 511 setChild(list, 2); 512 } 513 /** 514 * Retrieves the number of children in the TypeBound list. 515 * @return Number of children in the TypeBound list. 516 * @apilevel high-level 517 */ 518 public int getNumTypeBound() { 519 return getTypeBoundList().getNumChild(); 520 } 521 /** 522 * Retrieves the number of children in the TypeBound list. 523 * Calling this method will not trigger rewrites. 524 * @return Number of children in the TypeBound list. 525 * @apilevel low-level 526 */ 527 public int getNumTypeBoundNoTransform() { 528 return getTypeBoundListNoTransform().getNumChildNoTransform(); 529 } 530 /** 531 * Retrieves the element at index {@code i} in the TypeBound list. 532 * @param i Index of the element to return. 533 * @return The element at position {@code i} in the TypeBound list. 534 * @apilevel high-level 535 */ 536 public Access getTypeBound(int i) { 537 return (Access) getTypeBoundList().getChild(i); 538 } 539 /** 540 * Check whether the TypeBound list has any children. 541 * @return {@code true} if it has at least one child, {@code false} otherwise. 542 * @apilevel high-level 543 */ 544 public boolean hasTypeBound() { 545 return getTypeBoundList().getNumChild() != 0; 546 } 547 /** 548 * Append an element to the TypeBound list. 549 * @param node The element to append to the TypeBound list. 550 * @apilevel high-level 551 */ 552 public void addTypeBound(Access node) { 553 List<Access> list = (parent == null) ? getTypeBoundListNoTransform() : getTypeBoundList(); 554 list.addChild(node); 555 } 556 /** 557 * @apilevel low-level 558 */ 559 public void addTypeBoundNoTransform(Access node) { 560 List<Access> list = getTypeBoundListNoTransform(); 561 list.addChild(node); 562 } 563 /** 564 * Replaces the TypeBound list element at index {@code i} with the new node {@code node}. 565 * @param node The new node to replace the old list element. 566 * @param i The list index of the node to be replaced. 567 * @apilevel high-level 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 */ 578 @ASTNodeAnnotation.ListChild(name="TypeBound") 579 public List<Access> getTypeBoundList() { 580 List<Access> list = (List<Access>) getChild(2); 581 return list; 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 */ 589 public List<Access> getTypeBoundListNoTransform() { 590 return (List<Access>) getChildNoTransform(2); 591 } 592 /** 593 * Retrieves the TypeBound list. 594 * @return The node representing the TypeBound list. 595 * @apilevel high-level 596 */ 597 public List<Access> getTypeBounds() { 598 return getTypeBoundList(); 599 } 600 /** 601 * Retrieves the TypeBound list. 602 * <p><em>This method does not invoke AST transformations.</em></p> 603 * @return The node representing the TypeBound list. 604 * @apilevel low-level 605 */ 606 public List<Access> getTypeBoundsNoTransform() { 607 return getTypeBoundListNoTransform(); 608 } 609 /** 610 * @apilevel internal 611 */ 612 protected boolean unboxed_computed = false; 613 /** 614 * @apilevel internal 615 */ 616 protected TypeDecl unboxed_value; 617 /** 618 * @apilevel internal 619 */ 620 private void unboxed_reset() { 621 unboxed_computed = false; 622 unboxed_value = null; 623 } 624 /** 625 * @attribute syn 626 * @aspect AutoBoxing 627 * @declaredat /home/jesper/git/extendj/java5/frontend/AutoBoxing.jrag:72 628 */ 629 @ASTNodeAnnotation.Attribute 630 public TypeDecl unboxed() { 631 ASTNode$State state = state(); 632 if (unboxed_computed) { 633 return unboxed_value; 634 } 635 boolean intermediate = state.INTERMEDIATE_VALUE; 636 state.INTERMEDIATE_VALUE = false; 637 int num = state.boundariesCrossed; 638 boolean isFinal = this.is$Final(); 639 unboxed_value = unboxed_compute(); 640 if (isFinal && num == state().boundariesCrossed) { 641 unboxed_computed = true; 642 } else { 643 } 644 state.INTERMEDIATE_VALUE |= intermediate; 645 646 return unboxed_value; 647 } 648 /** 649 * @apilevel internal 650 */ 651 private TypeDecl unboxed_compute() { 652 for (Access bound: getTypeBoundList()) { 653 TypeDecl unboxed = bound.type().unboxed(); 654 if (!unboxed.isUnknown()) { 655 return unboxed; 656 } 657 } 658 return unknownType(); 659 } 660 /** 661 * @apilevel internal 662 */ 663 protected boolean toInterface_computed = false; 664 /** 665 * @apilevel internal 666 */ 667 protected TypeDecl toInterface_value; 668 /** 669 * @apilevel internal 670 */ 671 private void toInterface_reset() { 672 toInterface_computed = false; 673 toInterface_value = null; 674 } 675 /** 676 * @attribute syn 677 * @aspect GreatestLowerBoundFactory 678 * @declaredat /home/jesper/git/extendj/java5/frontend/GLBTypeFactory.jadd:33 679 */ 680 @ASTNodeAnnotation.Attribute 681 public TypeDecl toInterface() { 682 ASTNode$State state = state(); 683 if (toInterface_computed) { 684 return toInterface_value; 685 } 686 boolean intermediate = state.INTERMEDIATE_VALUE; 687 state.INTERMEDIATE_VALUE = false; 688 int num = state.boundariesCrossed; 689 boolean isFinal = this.is$Final(); 690 toInterface_value = toInterface_compute(); 691 toInterface_value.setParent(this); 692 toInterface_value.is$Final = true; 693 if (true) { 694 toInterface_computed = true; 695 } else { 696 } 697 state.INTERMEDIATE_VALUE |= intermediate; 698 699 return toInterface_value; 700 } 701 /** 702 * @apilevel internal 703 */ 704 private TypeDecl toInterface_compute() { 705 // convert var to interface 706 InterfaceDecl ITj = new InterfaceDecl(); 707 ITj.setID("ITj_" + hashCode()); 708 // I'm assuming that TypeVariable has no members of it's own. 709 // TODO: would it be enough to add only public members of a bound 710 // that is TypeVariable or ClassDecl and add other (interface) 711 // bounds as superinterfaces to ITj 712 // TODO: Is it really necessary to add public members to the new 713 // interface? Or is an empty interface more than enough since java 714 // has a nominal type system. 715 for (int i = 0; i < getNumTypeBound(); i++) { 716 TypeDecl bound = getTypeBound(i).type(); 717 for (int j = 0; j < bound.getNumBodyDecl(); j++) { 718 BodyDecl bd = bound.getBodyDecl(j); 719 if (bd instanceof FieldDeclaration) { 720 FieldDeclaration fd = (FieldDeclaration) bd.treeCopyNoTransform(); 721 if (fd.isPublic()) { 722 ITj.addBodyDecl(fd); 723 } 724 } else if (bd instanceof MethodDecl) { 725 MethodDecl md = (MethodDecl) bd; 726 if (md.isPublic()) { 727 ITj.addBodyDecl((BodyDecl) md.treeCopyNoTransform()); 728 } 729 } 730 } 731 } 732 return ITj; 733 } 734 /** 735 * Check if a type is in the bound of this type, given a specific 736 * parameterization of this type. 737 * 738 * See JLS SE7 $4.5 739 * 740 * @param argument argument type 741 * @param par a parameterization 742 * @return {@code true} if the argument type is in the bound of this type 743 * @attribute syn 744 * @aspect GenericBoundCheck 745 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericBoundCheck.jrag:63 746 */ 747 @ASTNodeAnnotation.Attribute 748 public boolean boundOf(TypeDecl argument, Parameterization par) { 749 { 750 for (int i = 0; i < getNumTypeBound(); ++i) { 751 TypeDecl bound = getTypeBound(i).type(); 752 if (bound.usesTypeVariable()) { 753 Access substituted = bound.substitute(par); 754 substituted.setParent(this); 755 bound = substituted.type(); 756 } 757 if (!argument.subtype(bound)) { 758 return false; 759 } 760 } 761 return true; 762 } 763 } 764 /** 765 * @attribute syn 766 * @aspect GenericBoundCheck 767 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericBoundCheck.jrag:80 768 */ 769 @ASTNodeAnnotation.Attribute 770 public boolean boundOfWildcard(WildcardType type) { 771 boolean boundOfWildcard_WildcardType_value = true; 772 773 return boundOfWildcard_WildcardType_value; 774 } 775 /** 776 * @attribute syn 777 * @aspect GenericBoundCheck 778 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericBoundCheck.jrag:83 779 */ 780 @ASTNodeAnnotation.Attribute 781 public boolean boundOfWildcardExtends(WildcardExtendsType type) { 782 boolean boundOfWildcardExtends_WildcardExtendsType_value = type.extendsType().subtype(this); 783 784 return boundOfWildcardExtends_WildcardExtendsType_value; 785 } 786 /** 787 * @attribute syn 788 * @aspect GenericBoundCheck 789 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericBoundCheck.jrag:87 790 */ 791 @ASTNodeAnnotation.Attribute 792 public boolean boundOfWildcardSuper(WildcardSuperType type) { 793 boolean boundOfWildcardSuper_WildcardSuperType_value = type.superType().subtype(this); 794 795 return boundOfWildcardSuper_WildcardSuperType_value; 796 } 797 /** 798 * @apilevel internal 799 */ 800 protected int involvesTypeParameters_visited = -1; 801 /** 802 * @apilevel internal 803 */ 804 private void involvesTypeParameters_reset() { 805 involvesTypeParameters_computed = false; 806 involvesTypeParameters_initialized = false; 807 involvesTypeParameters_visited = -1; 808 } 809 /** 810 * @apilevel internal 811 */ 812 protected boolean involvesTypeParameters_computed = false; 813 /** 814 * @apilevel internal 815 */ 816 protected boolean involvesTypeParameters_initialized = false; 817 /** 818 * @apilevel internal 819 */ 820 protected boolean involvesTypeParameters_value; 821 @ASTNodeAnnotation.Attribute 822 public boolean involvesTypeParameters() { 823 if (involvesTypeParameters_computed) { 824 return involvesTypeParameters_value; 825 } 826 ASTNode$State state = state(); 827 boolean new_involvesTypeParameters_value; 828 if (!involvesTypeParameters_initialized) { 829 involvesTypeParameters_initialized = true; 830 involvesTypeParameters_value = false; 831 } 832 if (!state.IN_CIRCLE) { 833 state.IN_CIRCLE = true; 834 int num = state.boundariesCrossed; 835 boolean isFinal = this.is$Final(); 836 do { 837 involvesTypeParameters_visited = state.CIRCLE_INDEX; 838 state.CHANGE = false; 839 new_involvesTypeParameters_value = true; 840 if (new_involvesTypeParameters_value != involvesTypeParameters_value) { 841 state.CHANGE = true; 842 } 843 involvesTypeParameters_value = new_involvesTypeParameters_value; 844 state.CIRCLE_INDEX++; 845 } while (state.CHANGE); 846 if (isFinal && num == state().boundariesCrossed) { 847 involvesTypeParameters_computed = true; 848 } else { 849 state.RESET_CYCLE = true; 850 boolean $tmp = true; 851 state.RESET_CYCLE = false; 852 involvesTypeParameters_computed = false; 853 involvesTypeParameters_initialized = false; 854 } 855 state.IN_CIRCLE = false; 856 state.INTERMEDIATE_VALUE = false; 857 return involvesTypeParameters_value; 858 } 859 if (involvesTypeParameters_visited != state.CIRCLE_INDEX) { 860 involvesTypeParameters_visited = state.CIRCLE_INDEX; 861 if (state.RESET_CYCLE) { 862 involvesTypeParameters_computed = false; 863 involvesTypeParameters_initialized = false; 864 involvesTypeParameters_visited = -1; 865 return involvesTypeParameters_value; 866 } 867 new_involvesTypeParameters_value = true; 868 if (new_involvesTypeParameters_value != involvesTypeParameters_value) { 869 state.CHANGE = true; 870 } 871 involvesTypeParameters_value = new_involvesTypeParameters_value; 872 state.INTERMEDIATE_VALUE = true; 873 return involvesTypeParameters_value; 874 } 875 state.INTERMEDIATE_VALUE = true; 876 return involvesTypeParameters_value; 877 } 878 /** 879 * @attribute syn 880 * @aspect GenericTypeVariables 881 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericTypeVariables.jrag:55 882 */ 883 @ASTNodeAnnotation.Attribute 884 public TypeDecl lowerBound() { 885 TypeDecl lowerBound_value = getTypeBound(0).type(); 886 887 return lowerBound_value; 888 } 889 /** 890 * @attribute syn 891 * @aspect MemberMethods 892 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupMethod.jrag:317 893 */ 894 @ASTNodeAnnotation.Attribute 895 public Collection<MethodDecl> memberMethods(String name) { 896 { 897 Collection list = new HashSet(); 898 for (int i = 0; i < getNumTypeBound(); i++) { 899 for (Iterator iter = getTypeBound(i).type().memberMethods(name).iterator(); iter.hasNext(); ) { 900 MethodDecl decl = (MethodDecl) iter.next(); 901 list.add(decl); 902 } 903 } 904 return list; 905 } 906 } 907 /** 908 * @apilevel internal 909 */ 910 protected java.util.Map memberFields_String_values; 911 /** 912 * @apilevel internal 913 */ 914 private void memberFields_String_reset() { 915 memberFields_String_values = null; 916 } 917 /** 918 * @attribute syn 919 * @aspect Fields 920 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:435 921 */ 922 @ASTNodeAnnotation.Attribute 923 public SimpleSet memberFields(String name) { 924 Object _parameters = name; 925 if (memberFields_String_values == null) memberFields_String_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 926 ASTNode$State state = state(); 927 if (memberFields_String_values.containsKey(_parameters)) { 928 return (SimpleSet) memberFields_String_values.get(_parameters); 929 } 930 boolean intermediate = state.INTERMEDIATE_VALUE; 931 state.INTERMEDIATE_VALUE = false; 932 int num = state.boundariesCrossed; 933 boolean isFinal = this.is$Final(); 934 SimpleSet memberFields_String_value = memberFields_compute(name); 935 if (isFinal && num == state().boundariesCrossed) { 936 memberFields_String_values.put(_parameters, memberFields_String_value); 937 } else { 938 } 939 state.INTERMEDIATE_VALUE |= intermediate; 940 941 return memberFields_String_value; 942 } 943 /** 944 * @apilevel internal 945 */ 946 private SimpleSet memberFields_compute(String name) { 947 SimpleSet set = SimpleSet.emptySet; 948 for (int i = 0; i < getNumTypeBound(); i++) { 949 for (Iterator iter = getTypeBound(i).type().memberFields(name).iterator(); iter.hasNext(); ) { 950 FieldDeclaration decl = (FieldDeclaration) iter.next(); 951 set = set.add(decl); 952 } 953 } 954 return set; 955 } 956 /** 957 * @apilevel internal 958 */ 959 protected java.util.Map castingConversionTo_TypeDecl_values; 960 /** 961 * @apilevel internal 962 */ 963 private void castingConversionTo_TypeDecl_reset() { 964 castingConversionTo_TypeDecl_values = null; 965 } 966 /** 967 * @attribute syn 968 * @aspect TypeConversion 969 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:109 970 */ 971 @ASTNodeAnnotation.Attribute 972 public boolean castingConversionTo(TypeDecl type) { 973 Object _parameters = type; 974 if (castingConversionTo_TypeDecl_values == null) castingConversionTo_TypeDecl_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 975 ASTNode$State state = state(); 976 if (castingConversionTo_TypeDecl_values.containsKey(_parameters)) { 977 return (Boolean) castingConversionTo_TypeDecl_values.get(_parameters); 978 } 979 boolean intermediate = state.INTERMEDIATE_VALUE; 980 state.INTERMEDIATE_VALUE = false; 981 int num = state.boundariesCrossed; 982 boolean isFinal = this.is$Final(); 983 boolean castingConversionTo_TypeDecl_value = castingConversionTo_compute(type); 984 if (isFinal && num == state().boundariesCrossed) { 985 castingConversionTo_TypeDecl_values.put(_parameters, castingConversionTo_TypeDecl_value); 986 } else { 987 } 988 state.INTERMEDIATE_VALUE |= intermediate; 989 990 return castingConversionTo_TypeDecl_value; 991 } 992 /** 993 * @apilevel internal 994 */ 995 private boolean castingConversionTo_compute(TypeDecl type) { 996 if (!type.isReferenceType()) { 997 return false; 998 } 999 if (getNumTypeBound() == 0) { 1000 return true; 1001 } 1002 for (int i = 0; i < getNumTypeBound(); i++) { 1003 if (getTypeBound(i).type().castingConversionTo(type)) { 1004 return true; 1005 } 1006 } 1007 return false; 1008 } 1009 /** 1010 * @attribute syn 1011 * @aspect Generics 1012 * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:195 1013 */ 1014 @ASTNodeAnnotation.Attribute 1015 public boolean isNestedType() { 1016 boolean isNestedType_value = false; 1017 1018 return isNestedType_value; 1019 } 1020 /** 1021 * @apilevel internal 1022 */ 1023 protected boolean erasure_computed = false; 1024 /** 1025 * @apilevel internal 1026 */ 1027 protected TypeDecl erasure_value; 1028 /** 1029 * @apilevel internal 1030 */ 1031 private void erasure_reset() { 1032 erasure_computed = false; 1033 erasure_value = null; 1034 } 1035 /** 1036 * @attribute syn 1037 * @aspect GenericsErasure 1038 * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:422 1039 */ 1040 @ASTNodeAnnotation.Attribute 1041 public TypeDecl erasure() { 1042 ASTNode$State state = state(); 1043 if (erasure_computed) { 1044 return erasure_value; 1045 } 1046 boolean intermediate = state.INTERMEDIATE_VALUE; 1047 state.INTERMEDIATE_VALUE = false; 1048 int num = state.boundariesCrossed; 1049 boolean isFinal = this.is$Final(); 1050 erasure_value = getTypeBound(0).type().erasure(); 1051 if (isFinal && num == state().boundariesCrossed) { 1052 erasure_computed = true; 1053 } else { 1054 } 1055 state.INTERMEDIATE_VALUE |= intermediate; 1056 1057 return erasure_value; 1058 } 1059 /** 1060 * @apilevel internal 1061 */ 1062 protected boolean fullName_computed = false; 1063 /** 1064 * @apilevel internal 1065 */ 1066 protected String fullName_value; 1067 /** 1068 * @apilevel internal 1069 */ 1070 private void fullName_reset() { 1071 fullName_computed = false; 1072 fullName_value = null; 1073 } 1074 /** 1075 * @attribute syn 1076 * @aspect TypeName 1077 * @declaredat /home/jesper/git/extendj/java4/frontend/QualifiedNames.jrag:80 1078 */ 1079 @ASTNodeAnnotation.Attribute 1080 public String fullName() { 1081 ASTNode$State state = state(); 1082 if (fullName_computed) { 1083 return fullName_value; 1084 } 1085 boolean intermediate = state.INTERMEDIATE_VALUE; 1086 state.INTERMEDIATE_VALUE = false; 1087 int num = state.boundariesCrossed; 1088 boolean isFinal = this.is$Final(); 1089 fullName_value = fullName_compute(); 1090 if (isFinal && num == state().boundariesCrossed) { 1091 fullName_computed = true; 1092 } else { 1093 } 1094 state.INTERMEDIATE_VALUE |= intermediate; 1095 1096 return fullName_value; 1097 } 1098 /** 1099 * @apilevel internal 1100 */ 1101 private String fullName_compute() { 1102 if (getParent().getParent() instanceof TypeDecl) { 1103 TypeDecl typeDecl = (TypeDecl) getParent().getParent(); 1104 return typeDecl.fullName() + "@" + name(); 1105 } 1106 return super.fullName(); 1107 } 1108 /** 1109 * @attribute syn 1110 * @aspect LookupParTypeDecl 1111 * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:806 1112 */ 1113 @ASTNodeAnnotation.Attribute 1114 public boolean sameSignature(Access a) { 1115 boolean sameSignature_Access_value = a.type() == this; 1116 1117 return sameSignature_Access_value; 1118 } 1119 /** 1120 * @apilevel internal 1121 */ 1122 protected boolean lubType_computed = false; 1123 /** 1124 * @apilevel internal 1125 */ 1126 protected TypeDecl lubType_value; 1127 /** 1128 * @apilevel internal 1129 */ 1130 private void lubType_reset() { 1131 lubType_computed = false; 1132 lubType_value = null; 1133 } 1134 /** 1135 * @attribute syn 1136 * @aspect LookupParTypeDecl 1137 * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:1094 1138 */ 1139 @ASTNodeAnnotation.Attribute 1140 public TypeDecl lubType() { 1141 ASTNode$State state = state(); 1142 if (lubType_computed) { 1143 return lubType_value; 1144 } 1145 boolean intermediate = state.INTERMEDIATE_VALUE; 1146 state.INTERMEDIATE_VALUE = false; 1147 int num = state.boundariesCrossed; 1148 boolean isFinal = this.is$Final(); 1149 lubType_value = lubType_compute(); 1150 if (isFinal && num == state().boundariesCrossed) { 1151 lubType_computed = true; 1152 } else { 1153 } 1154 state.INTERMEDIATE_VALUE |= intermediate; 1155 1156 return lubType_value; 1157 } 1158 /** 1159 * @apilevel internal 1160 */ 1161 private TypeDecl lubType_compute() { 1162 ArrayList<TypeDecl> list = new ArrayList<TypeDecl>(); 1163 for (int i = 0; i < getNumTypeBound(); i++) { 1164 list.add(getTypeBound(i).type()); 1165 } 1166 return lookupLUBType(list); 1167 } 1168 /** 1169 * @apilevel internal 1170 */ 1171 protected int usesTypeVariable_visited = -1; 1172 /** 1173 * @apilevel internal 1174 */ 1175 private void usesTypeVariable_reset() { 1176 usesTypeVariable_computed = false; 1177 usesTypeVariable_initialized = false; 1178 usesTypeVariable_visited = -1; 1179 } 1180 /** 1181 * @apilevel internal 1182 */ 1183 protected boolean usesTypeVariable_computed = false; 1184 /** 1185 * @apilevel internal 1186 */ 1187 protected boolean usesTypeVariable_initialized = false; 1188 /** 1189 * @apilevel internal 1190 */ 1191 protected boolean usesTypeVariable_value; 1192 @ASTNodeAnnotation.Attribute 1193 public boolean usesTypeVariable() { 1194 if (usesTypeVariable_computed) { 1195 return usesTypeVariable_value; 1196 } 1197 ASTNode$State state = state(); 1198 boolean new_usesTypeVariable_value; 1199 if (!usesTypeVariable_initialized) { 1200 usesTypeVariable_initialized = true; 1201 usesTypeVariable_value = false; 1202 } 1203 if (!state.IN_CIRCLE) { 1204 state.IN_CIRCLE = true; 1205 int num = state.boundariesCrossed; 1206 boolean isFinal = this.is$Final(); 1207 do { 1208 usesTypeVariable_visited = state.CIRCLE_INDEX; 1209 state.CHANGE = false; 1210 new_usesTypeVariable_value = true; 1211 if (new_usesTypeVariable_value != usesTypeVariable_value) { 1212 state.CHANGE = true; 1213 } 1214 usesTypeVariable_value = new_usesTypeVariable_value; 1215 state.CIRCLE_INDEX++; 1216 } while (state.CHANGE); 1217 if (isFinal && num == state().boundariesCrossed) { 1218 usesTypeVariable_computed = true; 1219 } else { 1220 state.RESET_CYCLE = true; 1221 boolean $tmp = true; 1222 state.RESET_CYCLE = false; 1223 usesTypeVariable_computed = false; 1224 usesTypeVariable_initialized = false; 1225 } 1226 state.IN_CIRCLE = false; 1227 state.INTERMEDIATE_VALUE = false; 1228 return usesTypeVariable_value; 1229 } 1230 if (usesTypeVariable_visited != state.CIRCLE_INDEX) { 1231 usesTypeVariable_visited = state.CIRCLE_INDEX; 1232 if (state.RESET_CYCLE) { 1233 usesTypeVariable_computed = false; 1234 usesTypeVariable_initialized = false; 1235 usesTypeVariable_visited = -1; 1236 return usesTypeVariable_value; 1237 } 1238 new_usesTypeVariable_value = true; 1239 if (new_usesTypeVariable_value != usesTypeVariable_value) { 1240 state.CHANGE = true; 1241 } 1242 usesTypeVariable_value = new_usesTypeVariable_value; 1243 state.INTERMEDIATE_VALUE = true; 1244 return usesTypeVariable_value; 1245 } 1246 state.INTERMEDIATE_VALUE = true; 1247 return usesTypeVariable_value; 1248 } 1249 /** 1250 * @apilevel internal 1251 */ 1252 protected java.util.Map accessibleFrom_TypeDecl_values; 1253 /** 1254 * @apilevel internal 1255 */ 1256 private void accessibleFrom_TypeDecl_reset() { 1257 accessibleFrom_TypeDecl_values = null; 1258 } 1259 /** 1260 * @attribute syn 1261 * @aspect AccessControl 1262 * @declaredat /home/jesper/git/extendj/java4/frontend/AccessControl.jrag:68 1263 */ 1264 @ASTNodeAnnotation.Attribute 1265 public boolean accessibleFrom(TypeDecl type) { 1266 Object _parameters = type; 1267 if (accessibleFrom_TypeDecl_values == null) accessibleFrom_TypeDecl_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 1268 ASTNode$State state = state(); 1269 if (accessibleFrom_TypeDecl_values.containsKey(_parameters)) { 1270 return (Boolean) accessibleFrom_TypeDecl_values.get(_parameters); 1271 } 1272 boolean intermediate = state.INTERMEDIATE_VALUE; 1273 state.INTERMEDIATE_VALUE = false; 1274 int num = state.boundariesCrossed; 1275 boolean isFinal = this.is$Final(); 1276 boolean accessibleFrom_TypeDecl_value = true; 1277 if (isFinal && num == state().boundariesCrossed) { 1278 accessibleFrom_TypeDecl_values.put(_parameters, accessibleFrom_TypeDecl_value); 1279 } else { 1280 } 1281 state.INTERMEDIATE_VALUE |= intermediate; 1282 1283 return accessibleFrom_TypeDecl_value; 1284 } 1285 /** 1286 * @apilevel internal 1287 */ 1288 protected boolean typeName_computed = false; 1289 /** 1290 * @apilevel internal 1291 */ 1292 protected String typeName_value; 1293 /** 1294 * @apilevel internal 1295 */ 1296 private void typeName_reset() { 1297 typeName_computed = false; 1298 typeName_value = null; 1299 } 1300 /** 1301 * @attribute syn 1302 * @aspect TypeName 1303 * @declaredat /home/jesper/git/extendj/java4/frontend/QualifiedNames.jrag:91 1304 */ 1305 @ASTNodeAnnotation.Attribute 1306 public String typeName() { 1307 ASTNode$State state = state(); 1308 if (typeName_computed) { 1309 return typeName_value; 1310 } 1311 boolean intermediate = state.INTERMEDIATE_VALUE; 1312 state.INTERMEDIATE_VALUE = false; 1313 int num = state.boundariesCrossed; 1314 boolean isFinal = this.is$Final(); 1315 typeName_value = name(); 1316 if (isFinal && num == state().boundariesCrossed) { 1317 typeName_computed = true; 1318 } else { 1319 } 1320 state.INTERMEDIATE_VALUE |= intermediate; 1321 1322 return typeName_value; 1323 } 1324 /** 1325 * @attribute syn 1326 * @aspect GenericsParTypeDecl 1327 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericsParTypeDecl.jrag:96 1328 */ 1329 @ASTNodeAnnotation.Attribute 1330 public boolean isTypeVariable() { 1331 boolean isTypeVariable_value = true; 1332 1333 return isTypeVariable_value; 1334 } 1335 /** 1336 * @attribute syn 1337 * @aspect GenericsSubtype 1338 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericsSubtype.jrag:66 1339 */ 1340 @ASTNodeAnnotation.Attribute 1341 public boolean supertypeWildcard(WildcardType type) { 1342 boolean supertypeWildcard_WildcardType_value = true; 1343 1344 return supertypeWildcard_WildcardType_value; 1345 } 1346 /** 1347 * @attribute syn 1348 * @aspect GenericsSubtype 1349 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericsSubtype.jrag:73 1350 */ 1351 @ASTNodeAnnotation.Attribute 1352 public boolean supertypeWildcardExtends(WildcardExtendsType type) { 1353 boolean supertypeWildcardExtends_WildcardExtendsType_value = type.extendsType().subtype(this); 1354 1355 return supertypeWildcardExtends_WildcardExtendsType_value; 1356 } 1357 /** 1358 * @attribute syn 1359 * @aspect GenericsSubtype 1360 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericsSubtype.jrag:81 1361 */ 1362 @ASTNodeAnnotation.Attribute 1363 public boolean supertypeWildcardSuper(WildcardSuperType type) { 1364 boolean supertypeWildcardSuper_WildcardSuperType_value = type.superType().subtype(this); 1365 1366 return supertypeWildcardSuper_WildcardSuperType_value; 1367 } 1368 /** 1369 * @apilevel internal 1370 */ 1371 private void sameStructure_TypeDecl_reset() { 1372 sameStructure_TypeDecl_values = null; 1373 } 1374 protected java.util.Map sameStructure_TypeDecl_values; 1375 @ASTNodeAnnotation.Attribute 1376 public boolean sameStructure(TypeDecl t) { 1377 Object _parameters = t; 1378 if (sameStructure_TypeDecl_values == null) sameStructure_TypeDecl_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 1379 ASTNode$State.CircularValue _value; 1380 if (sameStructure_TypeDecl_values.containsKey(_parameters)) { 1381 Object _o = sameStructure_TypeDecl_values.get(_parameters); 1382 if (!(_o instanceof ASTNode$State.CircularValue)) { 1383 return (Boolean) _o; 1384 } else { 1385 _value = (ASTNode$State.CircularValue) _o; 1386 } 1387 } else { 1388 _value = new ASTNode$State.CircularValue(); 1389 sameStructure_TypeDecl_values.put(_parameters, _value); 1390 _value.value = true; 1391 } 1392 ASTNode$State state = state(); 1393 boolean new_sameStructure_TypeDecl_value; 1394 if (!state.IN_CIRCLE) { 1395 state.IN_CIRCLE = true; 1396 int num = state.boundariesCrossed; 1397 boolean isFinal = this.is$Final(); 1398 // TODO: fixme 1399 // state().CIRCLE_INDEX = 1; 1400 do { 1401 _value.visited = state.CIRCLE_INDEX; 1402 state.CHANGE = false; 1403 new_sameStructure_TypeDecl_value = sameStructure_compute(t); 1404 if (new_sameStructure_TypeDecl_value != ((Boolean)_value.value)) { 1405 state.CHANGE = true; 1406 _value.value = new_sameStructure_TypeDecl_value; 1407 } 1408 state.CIRCLE_INDEX++; 1409 } while (state.CHANGE); 1410 if (isFinal && num == state().boundariesCrossed) { 1411 sameStructure_TypeDecl_values.put(_parameters, new_sameStructure_TypeDecl_value); 1412 } else { 1413 sameStructure_TypeDecl_values.remove(_parameters); 1414 state.RESET_CYCLE = true; 1415 boolean $tmp = sameStructure_compute(t); 1416 state.RESET_CYCLE = false; 1417 } 1418 state.IN_CIRCLE = false; 1419 state.INTERMEDIATE_VALUE = false; 1420 return new_sameStructure_TypeDecl_value; 1421 } 1422 if (state.CIRCLE_INDEX != _value.visited) { 1423 _value.visited = state.CIRCLE_INDEX; 1424 new_sameStructure_TypeDecl_value = sameStructure_compute(t); 1425 if (state.RESET_CYCLE) { 1426 sameStructure_TypeDecl_values.remove(_parameters); 1427 } 1428 else if (new_sameStructure_TypeDecl_value != ((Boolean)_value.value)) { 1429 state.CHANGE = true; 1430 _value.value = new_sameStructure_TypeDecl_value; 1431 } 1432 state.INTERMEDIATE_VALUE = true; 1433 return new_sameStructure_TypeDecl_value; 1434 } 1435 state.INTERMEDIATE_VALUE = true; 1436 return (Boolean) _value.value; 1437 } 1438 /** 1439 * @apilevel internal 1440 */ 1441 private boolean sameStructure_compute(TypeDecl t) { 1442 if (!(t instanceof TypeVariable)) { 1443 return false; 1444 } 1445 if (t == this) { 1446 return true; 1447 } 1448 TypeVariable type = (TypeVariable) t; 1449 if (type.getNumTypeBound() != getNumTypeBound()) { 1450 return false; 1451 } 1452 for (int i = 0; i < getNumTypeBound(); i++) { 1453 boolean found = false; 1454 for (int j = i; !found && j < getNumTypeBound(); j++) 1455 if (getTypeBound(i).type().sameStructure(type.getTypeBound(j).type())) { 1456 found = true; 1457 } 1458 if (!found) { 1459 return false; 1460 } 1461 } 1462 return true; 1463 } 1464 /** 1465 * @attribute syn 1466 * @aspect GenericsSubtype 1467 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericsSubtype.jrag:480 1468 */ 1469 @ASTNodeAnnotation.Attribute 1470 public boolean supertypeArrayDecl(ArrayDecl type) { 1471 { 1472 for (int i = 0; i < getNumTypeBound(); i++) 1473 if (type.subtype(getTypeBound(i).type())) { 1474 return true; 1475 } 1476 return false; 1477 } 1478 } 1479 /** 1480 * @apilevel internal 1481 */ 1482 private void subtype_TypeDecl_reset() { 1483 subtype_TypeDecl_values = null; 1484 } 1485 protected java.util.Map subtype_TypeDecl_values; 1486 @ASTNodeAnnotation.Attribute 1487 public boolean subtype(TypeDecl type) { 1488 Object _parameters = type; 1489 if (subtype_TypeDecl_values == null) subtype_TypeDecl_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 1490 ASTNode$State.CircularValue _value; 1491 if (subtype_TypeDecl_values.containsKey(_parameters)) { 1492 Object _o = subtype_TypeDecl_values.get(_parameters); 1493 if (!(_o instanceof ASTNode$State.CircularValue)) { 1494 return (Boolean) _o; 1495 } else { 1496 _value = (ASTNode$State.CircularValue) _o; 1497 } 1498 } else { 1499 _value = new ASTNode$State.CircularValue(); 1500 subtype_TypeDecl_values.put(_parameters, _value); 1501 _value.value = true; 1502 } 1503 ASTNode$State state = state(); 1504 boolean new_subtype_TypeDecl_value; 1505 if (!state.IN_CIRCLE) { 1506 state.IN_CIRCLE = true; 1507 int num = state.boundariesCrossed; 1508 boolean isFinal = this.is$Final(); 1509 // TODO: fixme 1510 // state().CIRCLE_INDEX = 1; 1511 do { 1512 _value.visited = state.CIRCLE_INDEX; 1513 state.CHANGE = false; 1514 new_subtype_TypeDecl_value = type.supertypeTypeVariable(this); 1515 if (new_subtype_TypeDecl_value != ((Boolean)_value.value)) { 1516 state.CHANGE = true; 1517 _value.value = new_subtype_TypeDecl_value; 1518 } 1519 state.CIRCLE_INDEX++; 1520 } while (state.CHANGE); 1521 if (isFinal && num == state().boundariesCrossed) { 1522 subtype_TypeDecl_values.put(_parameters, new_subtype_TypeDecl_value); 1523 } else { 1524 subtype_TypeDecl_values.remove(_parameters); 1525 state.RESET_CYCLE = true; 1526 boolean $tmp = type.supertypeTypeVariable(this); 1527 state.RESET_CYCLE = false; 1528 } 1529 state.IN_CIRCLE = false; 1530 state.INTERMEDIATE_VALUE = false; 1531 return new_subtype_TypeDecl_value; 1532 } 1533 if (state.CIRCLE_INDEX != _value.visited) { 1534 _value.visited = state.CIRCLE_INDEX; 1535 new_subtype_TypeDecl_value = type.supertypeTypeVariable(this); 1536 if (state.RESET_CYCLE) { 1537 subtype_TypeDecl_values.remove(_parameters); 1538 } 1539 else if (new_subtype_TypeDecl_value != ((Boolean)_value.value)) { 1540 state.CHANGE = true; 1541 _value.value = new_subtype_TypeDecl_value; 1542 } 1543 state.INTERMEDIATE_VALUE = true; 1544 return new_subtype_TypeDecl_value; 1545 } 1546 state.INTERMEDIATE_VALUE = true; 1547 return (Boolean) _value.value; 1548 } 1549 /** 1550 * @attribute syn 1551 * @aspect GenericsSubtype 1552 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericsSubtype.jrag:321 1553 */ 1554 @ASTNodeAnnotation.Attribute 1555 public boolean supertypeTypeVariable(TypeVariable type) { 1556 { 1557 if (type == this) { 1558 return true; 1559 } 1560 for (int i = 0; i < getNumTypeBound(); i++) { 1561 boolean found = false; 1562 for (int j = 0; !found && j < type.getNumTypeBound(); j++) { 1563 if (type.getSubstitutedTypeBound(j, this).type().subtype(getTypeBound(i).type())) { 1564 found = true; 1565 } 1566 } 1567 if (!found) { 1568 return false; 1569 } 1570 } 1571 return true; 1572 } 1573 } 1574 /** 1575 * @apilevel internal 1576 */ 1577 protected java.util.Map getSubstitutedTypeBound_int_TypeDecl_values; 1578 /** 1579 * @apilevel internal 1580 */ 1581 private void getSubstitutedTypeBound_int_TypeDecl_reset() { 1582 getSubstitutedTypeBound_int_TypeDecl_values = null; 1583 } 1584 /** 1585 * @attribute syn 1586 * @aspect GenericsSubtype 1587 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericsSubtype.jrag:350 1588 */ 1589 @ASTNodeAnnotation.Attribute 1590 public Access getSubstitutedTypeBound(int i, TypeDecl type) { 1591 java.util.List _parameters = new java.util.ArrayList(2); 1592 _parameters.add(i); 1593 _parameters.add(type); 1594 if (getSubstitutedTypeBound_int_TypeDecl_values == null) getSubstitutedTypeBound_int_TypeDecl_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 1595 ASTNode$State state = state(); 1596 if (getSubstitutedTypeBound_int_TypeDecl_values.containsKey(_parameters)) { 1597 return (Access) getSubstitutedTypeBound_int_TypeDecl_values.get(_parameters); 1598 } 1599 boolean intermediate = state.INTERMEDIATE_VALUE; 1600 state.INTERMEDIATE_VALUE = false; 1601 int num = state.boundariesCrossed; 1602 boolean isFinal = this.is$Final(); 1603 Access getSubstitutedTypeBound_int_TypeDecl_value = getSubstitutedTypeBound_compute(i, type); 1604 if (isFinal && num == state().boundariesCrossed) { 1605 getSubstitutedTypeBound_int_TypeDecl_values.put(_parameters, getSubstitutedTypeBound_int_TypeDecl_value); 1606 } else { 1607 } 1608 state.INTERMEDIATE_VALUE |= intermediate; 1609 1610 return getSubstitutedTypeBound_int_TypeDecl_value; 1611 } 1612 /** 1613 * @apilevel internal 1614 */ 1615 private Access getSubstitutedTypeBound_compute(int i, TypeDecl type) { 1616 Access bound = getTypeBound(i); 1617 if (!bound.type().usesTypeVariable()) { 1618 return bound; 1619 } 1620 final TypeDecl typeDecl = type; 1621 Access access = bound.type().substitute( 1622 new Parameterization() { 1623 public boolean isRawType() { 1624 return false; 1625 } 1626 public TypeDecl substitute(TypeVariable typeVariable) { 1627 return typeVariable == TypeVariable.this ? typeDecl : typeVariable; 1628 } 1629 } 1630 ); 1631 access.setParent(this); 1632 return access; 1633 } 1634 /** 1635 * @attribute syn 1636 * @aspect GenericsSubtype 1637 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericsSubtype.jrag:448 1638 */ 1639 @ASTNodeAnnotation.Attribute 1640 public boolean supertypeClassDecl(ClassDecl type) { 1641 boolean supertypeClassDecl_ClassDecl_value = false; 1642 1643 return supertypeClassDecl_ClassDecl_value; 1644 } 1645 /** 1646 * @attribute syn 1647 * @aspect GenericsSubtype 1648 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericsSubtype.jrag:465 1649 */ 1650 @ASTNodeAnnotation.Attribute 1651 public boolean supertypeInterfaceDecl(InterfaceDecl type) { 1652 boolean supertypeInterfaceDecl_InterfaceDecl_value = false; 1653 1654 return supertypeInterfaceDecl_InterfaceDecl_value; 1655 } 1656 /** 1657 * @apilevel internal 1658 */ 1659 protected java.util.Map instanceOf_TypeDecl_values; 1660 /** 1661 * @apilevel internal 1662 */ 1663 private void instanceOf_TypeDecl_reset() { 1664 instanceOf_TypeDecl_values = null; 1665 } 1666 /** 1667 * @attribute syn 1668 * @aspect TypeWideningAndIdentity 1669 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:442 1670 */ 1671 @ASTNodeAnnotation.Attribute 1672 public boolean instanceOf(TypeDecl type) { 1673 Object _parameters = type; 1674 if (instanceOf_TypeDecl_values == null) instanceOf_TypeDecl_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 1675 ASTNode$State state = state(); 1676 if (instanceOf_TypeDecl_values.containsKey(_parameters)) { 1677 return (Boolean) instanceOf_TypeDecl_values.get(_parameters); 1678 } 1679 boolean intermediate = state.INTERMEDIATE_VALUE; 1680 state.INTERMEDIATE_VALUE = false; 1681 int num = state.boundariesCrossed; 1682 boolean isFinal = this.is$Final(); 1683 boolean instanceOf_TypeDecl_value = subtype(type); 1684 if (isFinal && num == state().boundariesCrossed) { 1685 instanceOf_TypeDecl_values.put(_parameters, instanceOf_TypeDecl_value); 1686 } else { 1687 } 1688 state.INTERMEDIATE_VALUE |= intermediate; 1689 1690 return instanceOf_TypeDecl_value; 1691 } 1692 /** 1693 * A type is reifiable if it either refers to a non-parameterized type, 1694 * is a raw type, is a parameterized type with only unbound wildcard 1695 * parameters or is an array type with a reifiable type parameter. 1696 * 1697 * @see "JLS SE7 §4.7" 1698 * @attribute syn 1699 * @aspect ReifiableTypes 1700 * @declaredat /home/jesper/git/extendj/java5/frontend/ReifiableTypes.jrag:39 1701 */ 1702 @ASTNodeAnnotation.Attribute 1703 public boolean isReifiable() { 1704 boolean isReifiable_value = false; 1705 1706 return isReifiable_value; 1707 } 1708 /** 1709 * @apilevel internal 1710 */ 1711 protected boolean typeDescriptor_computed = false; 1712 /** 1713 * @apilevel internal 1714 */ 1715 protected String typeDescriptor_value; 1716 /** 1717 * @apilevel internal 1718 */ 1719 private void typeDescriptor_reset() { 1720 typeDescriptor_computed = false; 1721 typeDescriptor_value = null; 1722 } 1723 /** 1724 * @attribute syn 1725 * @aspect ConstantPoolNames 1726 * @declaredat /home/jesper/git/extendj/java4/backend/ConstantPoolNames.jrag:77 1727 */ 1728 @ASTNodeAnnotation.Attribute 1729 public String typeDescriptor() { 1730 ASTNode$State state = state(); 1731 if (typeDescriptor_computed) { 1732 return typeDescriptor_value; 1733 } 1734 boolean intermediate = state.INTERMEDIATE_VALUE; 1735 state.INTERMEDIATE_VALUE = false; 1736 int num = state.boundariesCrossed; 1737 boolean isFinal = this.is$Final(); 1738 typeDescriptor_value = erasure().typeDescriptor(); 1739 if (isFinal && num == state().boundariesCrossed) { 1740 typeDescriptor_computed = true; 1741 } else { 1742 } 1743 state.INTERMEDIATE_VALUE |= intermediate; 1744 1745 return typeDescriptor_value; 1746 } 1747 /** 1748 * @attribute syn 1749 * @aspect CreateBCode 1750 * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:900 1751 */ 1752 @ASTNodeAnnotation.Attribute 1753 public String arrayTypeDescriptor() { 1754 String arrayTypeDescriptor_value = erasure().arrayTypeDescriptor(); 1755 1756 return arrayTypeDescriptor_value; 1757 } 1758 /** 1759 * @apilevel internal 1760 */ 1761 protected boolean constantPoolName_computed = false; 1762 /** 1763 * @apilevel internal 1764 */ 1765 protected String constantPoolName_value; 1766 /** 1767 * @apilevel internal 1768 */ 1769 private void constantPoolName_reset() { 1770 constantPoolName_computed = false; 1771 constantPoolName_value = null; 1772 } 1773 /** 1774 * For a top-level type the constant pool name of the type is the same as the 1775 * canonical name but with dots replaced by solidus. 1776 * 1777 * <p>For nested types the constant pool name is based on the enclosing top-level 1778 * types constant pool name followed by a dollar sign and a unique index and/or 1779 * the type name. 1780 * 1781 * @return constant pool name of this type 1782 * @attribute syn 1783 * @aspect ConstantPoolNames 1784 * @declaredat /home/jesper/git/extendj/java4/backend/ConstantPoolNames.jrag:44 1785 */ 1786 @ASTNodeAnnotation.Attribute 1787 public String constantPoolName() { 1788 ASTNode$State state = state(); 1789 if (constantPoolName_computed) { 1790 return constantPoolName_value; 1791 } 1792 boolean intermediate = state.INTERMEDIATE_VALUE; 1793 state.INTERMEDIATE_VALUE = false; 1794 int num = state.boundariesCrossed; 1795 boolean isFinal = this.is$Final(); 1796 constantPoolName_value = erasure().constantPoolName(); 1797 if (isFinal && num == state().boundariesCrossed) { 1798 constantPoolName_computed = true; 1799 } else { 1800 } 1801 state.INTERMEDIATE_VALUE |= intermediate; 1802 1803 return constantPoolName_value; 1804 } 1805 /** 1806 * @apilevel internal 1807 */ 1808 protected boolean needsSignatureAttribute_computed = false; 1809 /** 1810 * @apilevel internal 1811 */ 1812 protected boolean needsSignatureAttribute_value; 1813 /** 1814 * @apilevel internal 1815 */ 1816 private void needsSignatureAttribute_reset() { 1817 needsSignatureAttribute_computed = false; 1818 } 1819 /** 1820 * @attribute syn 1821 * @aspect GenericsCodegen 1822 * @declaredat /home/jesper/git/extendj/java5/backend/GenericsCodegen.jrag:345 1823 */ 1824 @ASTNodeAnnotation.Attribute 1825 public boolean needsSignatureAttribute() { 1826 ASTNode$State state = state(); 1827 if (needsSignatureAttribute_computed) { 1828 return needsSignatureAttribute_value; 1829 } 1830 boolean intermediate = state.INTERMEDIATE_VALUE; 1831 state.INTERMEDIATE_VALUE = false; 1832 int num = state.boundariesCrossed; 1833 boolean isFinal = this.is$Final(); 1834 needsSignatureAttribute_value = true; 1835 if (isFinal && num == state().boundariesCrossed) { 1836 needsSignatureAttribute_computed = true; 1837 } else { 1838 } 1839 state.INTERMEDIATE_VALUE |= intermediate; 1840 1841 return needsSignatureAttribute_value; 1842 } 1843 /** 1844 * @attribute syn 1845 * @aspect GenericsCodegen 1846 * @declaredat /home/jesper/git/extendj/java5/backend/GenericsCodegen.jrag:448 1847 */ 1848 @ASTNodeAnnotation.Attribute 1849 public String formalTypeParameter() { 1850 { 1851 StringBuilder buf = new StringBuilder(); 1852 // Identifier 1853 buf.append(name()); 1854 buf.append(":"); 1855 if (getNumTypeBound() > 0) { 1856 // ClassBound InterfaceBound* 1857 if (getTypeBound(0).type().isClassDecl()) { 1858 buf.append(getTypeBound(0).type().fieldTypeSignature()); 1859 } else { 1860 buf.append(":" + getTypeBound(0).type().fieldTypeSignature()); 1861 } 1862 for (int i = 1; i < getNumTypeBound(); i++) { 1863 buf.append(":" + getTypeBound(i).type().fieldTypeSignature()); 1864 } 1865 } 1866 return buf.toString(); 1867 } 1868 } 1869 /** 1870 * @apilevel internal 1871 */ 1872 protected boolean fieldTypeSignature_computed = false; 1873 /** 1874 * @apilevel internal 1875 */ 1876 protected String fieldTypeSignature_value; 1877 /** 1878 * @apilevel internal 1879 */ 1880 private void fieldTypeSignature_reset() { 1881 fieldTypeSignature_computed = false; 1882 fieldTypeSignature_value = null; 1883 } 1884 /** 1885 * @attribute syn 1886 * @aspect GenericsCodegen 1887 * @declaredat /home/jesper/git/extendj/java5/backend/GenericsCodegen.jrag:467 1888 */ 1889 @ASTNodeAnnotation.Attribute 1890 public String fieldTypeSignature() { 1891 ASTNode$State state = state(); 1892 if (fieldTypeSignature_computed) { 1893 return fieldTypeSignature_value; 1894 } 1895 boolean intermediate = state.INTERMEDIATE_VALUE; 1896 state.INTERMEDIATE_VALUE = false; 1897 int num = state.boundariesCrossed; 1898 boolean isFinal = this.is$Final(); 1899 fieldTypeSignature_value = classTypeSignature(); 1900 if (isFinal && num == state().boundariesCrossed) { 1901 fieldTypeSignature_computed = true; 1902 } else { 1903 } 1904 state.INTERMEDIATE_VALUE |= intermediate; 1905 1906 return fieldTypeSignature_value; 1907 } 1908 /** 1909 * @apilevel internal 1910 */ 1911 protected boolean classTypeSignature_computed = false; 1912 /** 1913 * @apilevel internal 1914 */ 1915 protected String classTypeSignature_value; 1916 /** 1917 * @apilevel internal 1918 */ 1919 private void classTypeSignature_reset() { 1920 classTypeSignature_computed = false; 1921 classTypeSignature_value = null; 1922 } 1923 /** 1924 * @attribute syn 1925 * @aspect GenericsCodegen 1926 * @declaredat /home/jesper/git/extendj/java5/backend/GenericsCodegen.jrag:476 1927 */ 1928 @ASTNodeAnnotation.Attribute 1929 public String classTypeSignature() { 1930 ASTNode$State state = state(); 1931 if (classTypeSignature_computed) { 1932 return classTypeSignature_value; 1933 } 1934 boolean intermediate = state.INTERMEDIATE_VALUE; 1935 state.INTERMEDIATE_VALUE = false; 1936 int num = state.boundariesCrossed; 1937 boolean isFinal = this.is$Final(); 1938 classTypeSignature_value = "T" + name() + ";"; 1939 if (isFinal && num == state().boundariesCrossed) { 1940 classTypeSignature_computed = true; 1941 } else { 1942 } 1943 state.INTERMEDIATE_VALUE |= intermediate; 1944 1945 return classTypeSignature_value; 1946 } 1947 /** 1948 * @apilevel internal 1949 */ 1950 protected boolean classBound_computed = false; 1951 /** 1952 * @apilevel internal 1953 */ 1954 protected String classBound_value; 1955 /** 1956 * @apilevel internal 1957 */ 1958 private void classBound_reset() { 1959 classBound_computed = false; 1960 classBound_value = null; 1961 } 1962 /** 1963 * @attribute syn 1964 * @aspect GenericsCodegen 1965 * @declaredat /home/jesper/git/extendj/java5/backend/GenericsCodegen.jrag:532 1966 */ 1967 @ASTNodeAnnotation.Attribute 1968 public String classBound() { 1969 ASTNode$State state = state(); 1970 if (classBound_computed) { 1971 return classBound_value; 1972 } 1973 boolean intermediate = state.INTERMEDIATE_VALUE; 1974 state.INTERMEDIATE_VALUE = false; 1975 int num = state.boundariesCrossed; 1976 boolean isFinal = this.is$Final(); 1977 classBound_value = classBound_compute(); 1978 if (isFinal && num == state().boundariesCrossed) { 1979 classBound_computed = true; 1980 } else { 1981 } 1982 state.INTERMEDIATE_VALUE |= intermediate; 1983 1984 return classBound_value; 1985 } 1986 /** 1987 * @apilevel internal 1988 */ 1989 private String classBound_compute() { 1990 if (getNumTypeBound() > 0) { 1991 return getTypeBound(0).type().fieldTypeSignature(); 1992 } 1993 return ""; 1994 } 1995 /** 1996 * @apilevel internal 1997 */ 1998 protected boolean interfaceBounds_computed = false; 1999 /** 2000 * @apilevel internal 2001 */ 2002 protected String interfaceBounds_value; 2003 /** 2004 * @apilevel internal 2005 */ 2006 private void interfaceBounds_reset() { 2007 interfaceBounds_computed = false; 2008 interfaceBounds_value = null; 2009 } 2010 /** 2011 * @attribute syn 2012 * @aspect GenericsCodegen 2013 * @declaredat /home/jesper/git/extendj/java5/backend/GenericsCodegen.jrag:538 2014 */ 2015 @ASTNodeAnnotation.Attribute 2016 public String interfaceBounds() { 2017 ASTNode$State state = state(); 2018 if (interfaceBounds_computed) { 2019 return interfaceBounds_value; 2020 } 2021 boolean intermediate = state.INTERMEDIATE_VALUE; 2022 state.INTERMEDIATE_VALUE = false; 2023 int num = state.boundariesCrossed; 2024 boolean isFinal = this.is$Final(); 2025 interfaceBounds_value = interfaceBounds_compute(); 2026 if (isFinal && num == state().boundariesCrossed) { 2027 interfaceBounds_computed = true; 2028 } else { 2029 } 2030 state.INTERMEDIATE_VALUE |= intermediate; 2031 2032 return interfaceBounds_value; 2033 } 2034 /** 2035 * @apilevel internal 2036 */ 2037 private String interfaceBounds_compute() { 2038 StringBuilder buf = new StringBuilder(); 2039 for (int i = 1; i < getNumTypeBound(); ++i) { 2040 buf.append(":"); 2041 buf.append(getTypeBound(i).type().fieldTypeSignature()); 2042 } 2043 return buf.toString(); 2044 } 2045 /** 2046 * @attribute syn 2047 * @aspect StrictSubtype 2048 * @declaredat /home/jesper/git/extendj/java8/frontend/GenericsSubtype.jrag:68 2049 */ 2050 @ASTNodeAnnotation.Attribute 2051 public boolean strictSupertypeWildcard(WildcardType type) { 2052 boolean strictSupertypeWildcard_WildcardType_value = true; 2053 2054 return strictSupertypeWildcard_WildcardType_value; 2055 } 2056 /** 2057 * @attribute syn 2058 * @aspect StrictSubtype 2059 * @declaredat /home/jesper/git/extendj/java8/frontend/GenericsSubtype.jrag:77 2060 */ 2061 @ASTNodeAnnotation.Attribute 2062 public boolean strictSupertypeWildcardExtends(WildcardExtendsType type) { 2063 boolean strictSupertypeWildcardExtends_WildcardExtendsType_value = type.extendsType().strictSubtype(this); 2064 2065 return strictSupertypeWildcardExtends_WildcardExtendsType_value; 2066 } 2067 /** 2068 * @attribute syn 2069 * @aspect StrictSubtype 2070 * @declaredat /home/jesper/git/extendj/java8/frontend/GenericsSubtype.jrag:85 2071 */ 2072 @ASTNodeAnnotation.Attribute 2073 public boolean strictSupertypeWildcardSuper(WildcardSuperType type) { 2074 boolean strictSupertypeWildcardSuper_WildcardSuperType_value = type.superType().strictSubtype(this); 2075 2076 return strictSupertypeWildcardSuper_WildcardSuperType_value; 2077 } 2078 /** 2079 * @attribute syn 2080 * @aspect StrictSubtype 2081 * @declaredat /home/jesper/git/extendj/java8/frontend/GenericsSubtype.jrag:407 2082 */ 2083 @ASTNodeAnnotation.Attribute 2084 public boolean strictSupertypeArrayDecl(ArrayDecl type) { 2085 boolean strictSupertypeArrayDecl_ArrayDecl_value = false; 2086 2087 return strictSupertypeArrayDecl_ArrayDecl_value; 2088 } 2089 /** 2090 * @apilevel internal 2091 */ 2092 private void strictSubtype_TypeDecl_reset() { 2093 strictSubtype_TypeDecl_values = null; 2094 } 2095 protected java.util.Map strictSubtype_TypeDecl_values; 2096 @ASTNodeAnnotation.Attribute 2097 public boolean strictSubtype(TypeDecl type) { 2098 Object _parameters = type; 2099 if (strictSubtype_TypeDecl_values == null) strictSubtype_TypeDecl_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 2100 ASTNode$State.CircularValue _value; 2101 if (strictSubtype_TypeDecl_values.containsKey(_parameters)) { 2102 Object _o = strictSubtype_TypeDecl_values.get(_parameters); 2103 if (!(_o instanceof ASTNode$State.CircularValue)) { 2104 return (Boolean) _o; 2105 } else { 2106 _value = (ASTNode$State.CircularValue) _o; 2107 } 2108 } else { 2109 _value = new ASTNode$State.CircularValue(); 2110 strictSubtype_TypeDecl_values.put(_parameters, _value); 2111 _value.value = true; 2112 } 2113 ASTNode$State state = state(); 2114 boolean new_strictSubtype_TypeDecl_value; 2115 if (!state.IN_CIRCLE) { 2116 state.IN_CIRCLE = true; 2117 int num = state.boundariesCrossed; 2118 boolean isFinal = this.is$Final(); 2119 // TODO: fixme 2120 // state().CIRCLE_INDEX = 1; 2121 do { 2122 _value.visited = state.CIRCLE_INDEX; 2123 state.CHANGE = false; 2124 new_strictSubtype_TypeDecl_value = type.strictSupertypeTypeVariable(this); 2125 if (new_strictSubtype_TypeDecl_value != ((Boolean)_value.value)) { 2126 state.CHANGE = true; 2127 _value.value = new_strictSubtype_TypeDecl_value; 2128 } 2129 state.CIRCLE_INDEX++; 2130 } while (state.CHANGE); 2131 if (isFinal && num == state().boundariesCrossed) { 2132 strictSubtype_TypeDecl_values.put(_parameters, new_strictSubtype_TypeDecl_value); 2133 } else { 2134 strictSubtype_TypeDecl_values.remove(_parameters); 2135 state.RESET_CYCLE = true; 2136 boolean $tmp = type.strictSupertypeTypeVariable(this); 2137 state.RESET_CYCLE = false; 2138 } 2139 state.IN_CIRCLE = false; 2140 state.INTERMEDIATE_VALUE = false; 2141 return new_strictSubtype_TypeDecl_value; 2142 } 2143 if (state.CIRCLE_INDEX != _value.visited) { 2144 _value.visited = state.CIRCLE_INDEX; 2145 new_strictSubtype_TypeDecl_value = type.strictSupertypeTypeVariable(this); 2146 if (state.RESET_CYCLE) { 2147 strictSubtype_TypeDecl_values.remove(_parameters); 2148 } 2149 else if (new_strictSubtype_TypeDecl_value != ((Boolean)_value.value)) { 2150 state.CHANGE = true; 2151 _value.value = new_strictSubtype_TypeDecl_value; 2152 } 2153 state.INTERMEDIATE_VALUE = true; 2154 return new_strictSubtype_TypeDecl_value; 2155 } 2156 state.INTERMEDIATE_VALUE = true; 2157 return (Boolean) _value.value; 2158 } 2159 /** 2160 * @attribute syn 2161 * @aspect StrictSubtype 2162 * @declaredat /home/jesper/git/extendj/java8/frontend/GenericsSubtype.jrag:276 2163 */ 2164 @ASTNodeAnnotation.Attribute 2165 public boolean strictSupertypeTypeVariable(TypeVariable type) { 2166 { 2167 if (typeVarInMethod() && type.typeVarInMethod() 2168 && genericMethodLevel() == type.genericMethodLevel()) { 2169 if (typeVarPosition() == type.typeVarPosition() || this == type) { 2170 return true; 2171 } 2172 } else { 2173 if (this == type) { 2174 return true; 2175 } 2176 } 2177 for (int i = 0; i < type.getNumTypeBound(); i++) { 2178 if (type.getTypeBound(i).type().strictSubtype(this)) { 2179 return true; 2180 } 2181 } 2182 return false; 2183 } 2184 } 2185 /** 2186 * @attribute syn 2187 * @aspect StrictSubtype 2188 * @declaredat /home/jesper/git/extendj/java8/frontend/GenericsSubtype.jrag:370 2189 */ 2190 @ASTNodeAnnotation.Attribute 2191 public boolean strictSupertypeClassDecl(ClassDecl type) { 2192 { 2193 return false; 2194 } 2195 } 2196 /** 2197 * @attribute syn 2198 * @aspect StrictSubtype 2199 * @declaredat /home/jesper/git/extendj/java8/frontend/GenericsSubtype.jrag:390 2200 */ 2201 @ASTNodeAnnotation.Attribute 2202 public boolean strictSupertypeInterfaceDecl(InterfaceDecl type) { 2203 { 2204 return false; 2205 } 2206 } 2207 /** 2208 * @attribute inh 2209 * @aspect LookupParTypeDecl 2210 * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:1092 2211 */ 2212 /** 2213 * @attribute inh 2214 * @aspect LookupParTypeDecl 2215 * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:1092 2216 */ 2217 @ASTNodeAnnotation.Attribute 2218 public TypeDecl typeObject() { 2219 TypeDecl typeObject_value = getParent().Define_typeObject(this, null); 2220 2221 return typeObject_value; 2222 } 2223 /** 2224 * @attribute inh 2225 * @aspect LookupParTypeDecl 2226 * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:1141 2227 */ 2228 /** 2229 * @attribute inh 2230 * @aspect LookupParTypeDecl 2231 * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:1141 2232 */ 2233 @ASTNodeAnnotation.Attribute 2234 public TypeDecl typeNull() { 2235 TypeDecl typeNull_value = getParent().Define_typeNull(this, null); 2236 2237 return typeNull_value; 2238 } 2239 /** 2240 * @attribute inh 2241 * @aspect TypeVariablePositions 2242 * @declaredat /home/jesper/git/extendj/java8/frontend/TypeVariablePositions.jrag:29 2243 */ 2244 /** 2245 * @attribute inh 2246 * @aspect TypeVariablePositions 2247 * @declaredat /home/jesper/git/extendj/java8/frontend/TypeVariablePositions.jrag:29 2248 */ 2249 @ASTNodeAnnotation.Attribute 2250 public int typeVarPosition() { 2251 ASTNode$State state = state(); 2252 if (typeVarPosition_computed) { 2253 return typeVarPosition_value; 2254 } 2255 boolean intermediate = state.INTERMEDIATE_VALUE; 2256 state.INTERMEDIATE_VALUE = false; 2257 int num = state.boundariesCrossed; 2258 boolean isFinal = this.is$Final(); 2259 typeVarPosition_value = getParent().Define_typeVarPosition(this, null); 2260 if (isFinal && num == state().boundariesCrossed) { 2261 typeVarPosition_computed = true; 2262 } else { 2263 } 2264 state.INTERMEDIATE_VALUE |= intermediate; 2265 2266 return typeVarPosition_value; 2267 } 2268 /** 2269 * @apilevel internal 2270 */ 2271 protected boolean typeVarPosition_computed = false; 2272 /** 2273 * @apilevel internal 2274 */ 2275 protected int typeVarPosition_value; 2276 /** 2277 * @apilevel internal 2278 */ 2279 private void typeVarPosition_reset() { 2280 typeVarPosition_computed = false; 2281 } 2282 /** 2283 * @attribute inh 2284 * @aspect TypeVariablePositions 2285 * @declaredat /home/jesper/git/extendj/java8/frontend/TypeVariablePositions.jrag:30 2286 */ 2287 /** 2288 * @attribute inh 2289 * @aspect TypeVariablePositions 2290 * @declaredat /home/jesper/git/extendj/java8/frontend/TypeVariablePositions.jrag:30 2291 */ 2292 @ASTNodeAnnotation.Attribute 2293 public int genericMethodLevel() { 2294 ASTNode$State state = state(); 2295 if (genericMethodLevel_computed) { 2296 return genericMethodLevel_value; 2297 } 2298 boolean intermediate = state.INTERMEDIATE_VALUE; 2299 state.INTERMEDIATE_VALUE = false; 2300 int num = state.boundariesCrossed; 2301 boolean isFinal = this.is$Final(); 2302 genericMethodLevel_value = getParent().Define_genericMethodLevel(this, null); 2303 if (isFinal && num == state().boundariesCrossed) { 2304 genericMethodLevel_computed = true; 2305 } else { 2306 } 2307 state.INTERMEDIATE_VALUE |= intermediate; 2308 2309 return genericMethodLevel_value; 2310 } 2311 /** 2312 * @apilevel internal 2313 */ 2314 protected boolean genericMethodLevel_computed = false; 2315 /** 2316 * @apilevel internal 2317 */ 2318 protected int genericMethodLevel_value; 2319 /** 2320 * @apilevel internal 2321 */ 2322 private void genericMethodLevel_reset() { 2323 genericMethodLevel_computed = false; 2324 } 2325 /** 2326 * @attribute inh 2327 * @aspect TypeVariablePositions 2328 * @declaredat /home/jesper/git/extendj/java8/frontend/TypeVariablePositions.jrag:32 2329 */ 2330 /** 2331 * @attribute inh 2332 * @aspect TypeVariablePositions 2333 * @declaredat /home/jesper/git/extendj/java8/frontend/TypeVariablePositions.jrag:32 2334 */ 2335 @ASTNodeAnnotation.Attribute 2336 public boolean typeVarInMethod() { 2337 ASTNode$State state = state(); 2338 if (typeVarInMethod_computed) { 2339 return typeVarInMethod_value; 2340 } 2341 boolean intermediate = state.INTERMEDIATE_VALUE; 2342 state.INTERMEDIATE_VALUE = false; 2343 int num = state.boundariesCrossed; 2344 boolean isFinal = this.is$Final(); 2345 typeVarInMethod_value = getParent().Define_typeVarInMethod(this, null); 2346 if (isFinal && num == state().boundariesCrossed) { 2347 typeVarInMethod_computed = true; 2348 } else { 2349 } 2350 state.INTERMEDIATE_VALUE |= intermediate; 2351 2352 return typeVarInMethod_value; 2353 } 2354 /** 2355 * @apilevel internal 2356 */ 2357 protected boolean typeVarInMethod_computed = false; 2358 /** 2359 * @apilevel internal 2360 */ 2361 protected boolean typeVarInMethod_value; 2362 /** 2363 * @apilevel internal 2364 */ 2365 private void typeVarInMethod_reset() { 2366 typeVarInMethod_computed = false; 2367 } 2368 /** 2369 * @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:36 2370 * @apilevel internal 2371 */ 2372 public NameType Define_nameType(ASTNode caller, ASTNode child) { 2373 if (caller == getTypeBoundListNoTransform()) { 2374 // @declaredat /home/jesper/git/extendj/java5/frontend/GenericTypeVariables.jrag:34 2375 int childIndex = caller.getIndexOfChild(child); 2376 return NameType.TYPE_NAME; 2377 } 2378 else { 2379 return super.Define_nameType(caller, child); 2380 } 2381 } 2382 protected boolean canDefine_nameType(ASTNode caller, ASTNode child) { 2383 return true; 2384 } 2385 /** 2386 * @apilevel internal 2387 */ 2388 public ASTNode rewriteTo() { 2389 // Declared at /home/jesper/git/extendj/java5/frontend/GenericTypeVariables.jrag:37 2390 if (getNumTypeBound() == 0) { 2391 return rewriteRule0(); 2392 } 2393 return super.rewriteTo(); 2394 } 2395 /** 2396 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericTypeVariables.jrag:37 2397 * @apilevel internal 2398 */ 2399 private TypeVariable rewriteRule0() { 2400 { 2401 addTypeBound( 2402 new TypeAccess( 2403 "java.lang", 2404 "Object" 2405 ) 2406 ); 2407 return this; 2408 } } 2409 }