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 WildcardType : {@link AbstractWildcardType}; 015 * @ast node 016 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.ast:26 017 */ 018 public class WildcardType extends AbstractWildcardType 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 WildcardType clone() throws CloneNotSupportedException { 034 WildcardType node = (WildcardType)super.clone(); 035 node.subtype_TypeDecl_values = null; 036 node.containedIn_TypeDecl_values = null; 037 node.instanceOf_TypeDecl_values = null; 038 node.fieldTypeSignature_computed = false; 039 node.fieldTypeSignature_value = null; 040 node.in$Circle(false); 041 node.is$Final(false); 042 return node; 043 } 044 /** 045 * @apilevel internal 046 */ 047 @SuppressWarnings({"unchecked", "cast"}) 048 public WildcardType copy() { 049 050 try { 051 WildcardType node = (WildcardType) clone(); 052 node.parent = null; 053 if(children != null) 054 node.children = (ASTNode[]) children.clone(); 055 056 return node; 057 } catch (CloneNotSupportedException e) { 058 throw new Error("Error: clone not supported for " + getClass().getName()); 059 } 060 061 }/** 062 * Create a deep copy of the AST subtree at this node. 063 * The copy is dangling, i.e. has no parent. 064 * @return dangling copy of the subtree at this node 065 * @apilevel low-level 066 */ 067 @SuppressWarnings({"unchecked", "cast"}) 068 public WildcardType fullCopy() { 069 070 WildcardType tree = (WildcardType) copy(); 071 if (children != null) { 072 for (int i = 0; i < children.length; ++i) { 073 074 ASTNode child = (ASTNode) children[i]; 075 if(child != null) { 076 child = child.fullCopy(); 077 tree.setChild(child, i); 078 } 079 } 080 } 081 return tree; 082 083 } /** 084 * @ast method 085 * 086 */ 087 public WildcardType() { 088 super(); 089 090 091 } 092 /** 093 * Initializes the child array to the correct size. 094 * Initializes List and Opt nta children. 095 * @apilevel internal 096 * @ast method 097 * @ast method 098 * 099 */ 100 public void init$Children() { 101 children = new ASTNode[2]; 102 setChild(new List(), 1); 103 } 104 /** 105 * @ast method 106 * 107 */ 108 public WildcardType(Modifiers p0, String p1, List<BodyDecl> p2) { 109 setChild(p0, 0); 110 setID(p1); 111 setChild(p2, 1); 112 } 113 /** 114 * @ast method 115 * 116 */ 117 public WildcardType(Modifiers p0, beaver.Symbol p1, List<BodyDecl> p2) { 118 setChild(p0, 0); 119 setID(p1); 120 setChild(p2, 1); 121 } 122 /** 123 * @apilevel low-level 124 * @ast method 125 * 126 */ 127 protected int numChildren() { 128 return 2; 129 } 130 /** 131 * @apilevel internal 132 * @ast method 133 * 134 */ 135 public boolean mayHaveRewrite() { 136 return false; 137 } 138 /** 139 * Replaces the Modifiers child. 140 * @param node The new node to replace the Modifiers child. 141 * @apilevel high-level 142 * @ast method 143 * 144 */ 145 public void setModifiers(Modifiers node) { 146 setChild(node, 0); 147 } 148 /** 149 * Retrieves the Modifiers child. 150 * @return The current node used as the Modifiers child. 151 * @apilevel high-level 152 * @ast method 153 * 154 */ 155 public Modifiers getModifiers() { 156 return (Modifiers)getChild(0); 157 } 158 /** 159 * Retrieves the Modifiers child. 160 * <p><em>This method does not invoke AST transformations.</em></p> 161 * @return The current node used as the Modifiers child. 162 * @apilevel low-level 163 * @ast method 164 * 165 */ 166 public Modifiers getModifiersNoTransform() { 167 return (Modifiers)getChildNoTransform(0); 168 } 169 /** 170 * Replaces the lexeme ID. 171 * @param value The new value for the lexeme ID. 172 * @apilevel high-level 173 * @ast method 174 * 175 */ 176 public void setID(String value) { 177 tokenString_ID = value; 178 } 179 /** 180 * JastAdd-internal setter for lexeme ID using the Beaver parser. 181 * @apilevel internal 182 * @ast method 183 * 184 */ 185 public void setID(beaver.Symbol symbol) { 186 if(symbol.value != null && !(symbol.value instanceof String)) 187 throw new UnsupportedOperationException("setID is only valid for String lexemes"); 188 tokenString_ID = (String)symbol.value; 189 IDstart = symbol.getStart(); 190 IDend = symbol.getEnd(); 191 } 192 /** 193 * Retrieves the value for the lexeme ID. 194 * @return The value for the lexeme ID. 195 * @apilevel high-level 196 * @ast method 197 * 198 */ 199 public String getID() { 200 return tokenString_ID != null ? tokenString_ID : ""; 201 } 202 /** 203 * Replaces the BodyDecl list. 204 * @param list The new list node to be used as the BodyDecl list. 205 * @apilevel high-level 206 * @ast method 207 * 208 */ 209 public void setBodyDeclList(List<BodyDecl> list) { 210 setChild(list, 1); 211 } 212 /** 213 * Retrieves the number of children in the BodyDecl list. 214 * @return Number of children in the BodyDecl list. 215 * @apilevel high-level 216 * @ast method 217 * 218 */ 219 public int getNumBodyDecl() { 220 return getBodyDeclList().getNumChild(); 221 } 222 /** 223 * Retrieves the number of children in the BodyDecl list. 224 * Calling this method will not trigger rewrites.. 225 * @return Number of children in the BodyDecl list. 226 * @apilevel low-level 227 * @ast method 228 * 229 */ 230 public int getNumBodyDeclNoTransform() { 231 return getBodyDeclListNoTransform().getNumChildNoTransform(); 232 } 233 /** 234 * Retrieves the element at index {@code i} in the BodyDecl list.. 235 * @param i Index of the element to return. 236 * @return The element at position {@code i} in the BodyDecl list. 237 * @apilevel high-level 238 * @ast method 239 * 240 */ 241 @SuppressWarnings({"unchecked", "cast"}) 242 public BodyDecl getBodyDecl(int i) { 243 return (BodyDecl)getBodyDeclList().getChild(i); 244 } 245 /** 246 * Append an element to the BodyDecl list. 247 * @param node The element to append to the BodyDecl list. 248 * @apilevel high-level 249 * @ast method 250 * 251 */ 252 public void addBodyDecl(BodyDecl node) { 253 List<BodyDecl> list = (parent == null || state == null) ? getBodyDeclListNoTransform() : getBodyDeclList(); 254 list.addChild(node); 255 } 256 /** 257 * @apilevel low-level 258 * @ast method 259 * 260 */ 261 public void addBodyDeclNoTransform(BodyDecl node) { 262 List<BodyDecl> list = getBodyDeclListNoTransform(); 263 list.addChild(node); 264 } 265 /** 266 * Replaces the BodyDecl list element at index {@code i} with the new node {@code node}. 267 * @param node The new node to replace the old list element. 268 * @param i The list index of the node to be replaced. 269 * @apilevel high-level 270 * @ast method 271 * 272 */ 273 public void setBodyDecl(BodyDecl node, int i) { 274 List<BodyDecl> list = getBodyDeclList(); 275 list.setChild(node, i); 276 } 277 /** 278 * Retrieves the BodyDecl list. 279 * @return The node representing the BodyDecl list. 280 * @apilevel high-level 281 * @ast method 282 * 283 */ 284 public List<BodyDecl> getBodyDecls() { 285 return getBodyDeclList(); 286 } 287 /** 288 * Retrieves the BodyDecl list. 289 * <p><em>This method does not invoke AST transformations.</em></p> 290 * @return The node representing the BodyDecl list. 291 * @apilevel low-level 292 * @ast method 293 * 294 */ 295 public List<BodyDecl> getBodyDeclsNoTransform() { 296 return getBodyDeclListNoTransform(); 297 } 298 /** 299 * Retrieves the BodyDecl list. 300 * @return The node representing the BodyDecl list. 301 * @apilevel high-level 302 * @ast method 303 * 304 */ 305 @SuppressWarnings({"unchecked", "cast"}) 306 public List<BodyDecl> getBodyDeclList() { 307 List<BodyDecl> list = (List<BodyDecl>)getChild(1); 308 list.getNumChild(); 309 return list; 310 } 311 /** 312 * Retrieves the BodyDecl list. 313 * <p><em>This method does not invoke AST transformations.</em></p> 314 * @return The node representing the BodyDecl list. 315 * @apilevel low-level 316 * @ast method 317 * 318 */ 319 @SuppressWarnings({"unchecked", "cast"}) 320 public List<BodyDecl> getBodyDeclListNoTransform() { 321 return (List<BodyDecl>)getChildNoTransform(1); 322 } 323 /** 324 * @attribute syn 325 * @aspect LookupParTypeDecl 326 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Generics.jrag:571 327 */ 328 public boolean sameSignature(Access a) { 329 ASTNode$State state = state(); 330 try { 331 if(a instanceof Wildcard) 332 return true; 333 return super.sameSignature(a); 334 } 335 finally { 336 } 337 } 338 protected java.util.Map subtype_TypeDecl_values; 339 /** 340 * @attribute syn 341 * @aspect GenericsSubtype 342 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:45 343 */ 344 @SuppressWarnings({"unchecked", "cast"}) 345 public boolean subtype(TypeDecl type) { 346 Object _parameters = type; 347 if(subtype_TypeDecl_values == null) subtype_TypeDecl_values = new java.util.HashMap(4); 348 ASTNode$State.CircularValue _value; 349 if(subtype_TypeDecl_values.containsKey(_parameters)) { 350 Object _o = subtype_TypeDecl_values.get(_parameters); 351 if(!(_o instanceof ASTNode$State.CircularValue)) { 352 return ((Boolean)_o).booleanValue(); 353 } 354 else 355 _value = (ASTNode$State.CircularValue)_o; 356 } 357 else { 358 _value = new ASTNode$State.CircularValue(); 359 subtype_TypeDecl_values.put(_parameters, _value); 360 _value.value = Boolean.valueOf(true); 361 } 362 ASTNode$State state = state(); 363 if (!state.IN_CIRCLE) { 364 state.IN_CIRCLE = true; 365 int num = state.boundariesCrossed; 366 boolean isFinal = this.is$Final(); 367 boolean new_subtype_TypeDecl_value; 368 do { 369 _value.visited = new Integer(state.CIRCLE_INDEX); 370 state.CHANGE = false; 371 new_subtype_TypeDecl_value = subtype_compute(type); 372 if (new_subtype_TypeDecl_value!=((Boolean)_value.value).booleanValue()) { 373 state.CHANGE = true; 374 _value.value = Boolean.valueOf(new_subtype_TypeDecl_value); 375 } 376 state.CIRCLE_INDEX++; 377 } while (state.CHANGE); 378 if(isFinal && num == state().boundariesCrossed) { 379 subtype_TypeDecl_values.put(_parameters, new_subtype_TypeDecl_value); 380 } 381 else { 382 subtype_TypeDecl_values.remove(_parameters); 383 state.RESET_CYCLE = true; 384 subtype_compute(type); 385 state.RESET_CYCLE = false; 386 } 387 state.IN_CIRCLE = false; 388 return new_subtype_TypeDecl_value; 389 } 390 if(!new Integer(state.CIRCLE_INDEX).equals(_value.visited)) { 391 _value.visited = new Integer(state.CIRCLE_INDEX); 392 boolean new_subtype_TypeDecl_value = subtype_compute(type); 393 if (state.RESET_CYCLE) { 394 subtype_TypeDecl_values.remove(_parameters); 395 } 396 else if (new_subtype_TypeDecl_value!=((Boolean)_value.value).booleanValue()) { 397 state.CHANGE = true; 398 _value.value = new_subtype_TypeDecl_value; 399 } 400 return new_subtype_TypeDecl_value; 401 } 402 return ((Boolean)_value.value).booleanValue(); 403 } 404 /** 405 * @apilevel internal 406 */ 407 private boolean subtype_compute(TypeDecl type) { return type.supertypeWildcard(this); } 408 /** 409 * @attribute syn 410 * @aspect GenericsSubtype 411 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:46 412 */ 413 public boolean supertypeWildcard(WildcardType type) { 414 ASTNode$State state = state(); 415 try { return true; } 416 finally { 417 } 418 } 419 /** 420 * @attribute syn 421 * @aspect GenericsSubtype 422 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:57 423 */ 424 public boolean supertypeWildcardExtends(WildcardExtendsType type) { 425 ASTNode$State state = state(); 426 try { return true; } 427 finally { 428 } 429 } 430 /** 431 * @attribute syn 432 * @aspect GenericsSubtype 433 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:66 434 */ 435 public boolean supertypeWildcardSuper(WildcardSuperType type) { 436 ASTNode$State state = state(); 437 try { return true; } 438 finally { 439 } 440 } 441 /** 442 * @attribute syn 443 * @aspect GenericsSubtype 444 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:421 445 */ 446 public boolean supertypeClassDecl(ClassDecl type) { 447 ASTNode$State state = state(); 448 try { return true; } 449 finally { 450 } 451 } 452 /** 453 * @attribute syn 454 * @aspect GenericsSubtype 455 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:437 456 */ 457 public boolean supertypeInterfaceDecl(InterfaceDecl type) { 458 ASTNode$State state = state(); 459 try { return true; } 460 finally { 461 } 462 } 463 /** 464 * @attribute syn 465 * @aspect GenericsSubtype 466 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:125 467 */ 468 public boolean supertypeParClassDecl(ParClassDecl type) { 469 ASTNode$State state = state(); 470 try { return true; } 471 finally { 472 } 473 } 474 /** 475 * @attribute syn 476 * @aspect GenericsSubtype 477 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:129 478 */ 479 public boolean supertypeParInterfaceDecl(ParInterfaceDecl type) { 480 ASTNode$State state = state(); 481 try { return true; } 482 finally { 483 } 484 } 485 /** 486 * @attribute syn 487 * @aspect GenericsSubtype 488 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:26 489 */ 490 public boolean supertypeRawClassDecl(RawClassDecl type) { 491 ASTNode$State state = state(); 492 try { return true; } 493 finally { 494 } 495 } 496 /** 497 * @attribute syn 498 * @aspect GenericsSubtype 499 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:30 500 */ 501 public boolean supertypeRawInterfaceDecl(RawInterfaceDecl type) { 502 ASTNode$State state = state(); 503 try { return true; } 504 finally { 505 } 506 } 507 /** 508 * @attribute syn 509 * @aspect GenericsSubtype 510 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:291 511 */ 512 public boolean supertypeTypeVariable(TypeVariable type) { 513 ASTNode$State state = state(); 514 try { return true; } 515 finally { 516 } 517 } 518 /** 519 * @attribute syn 520 * @aspect GenericsSubtype 521 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:450 522 */ 523 public boolean supertypeArrayDecl(ArrayDecl type) { 524 ASTNode$State state = state(); 525 try { return true; } 526 finally { 527 } 528 } 529 protected java.util.Map containedIn_TypeDecl_values; 530 /** 531 * @attribute syn 532 * @aspect GenericsSubtype 533 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:169 534 */ 535 @SuppressWarnings({"unchecked", "cast"}) 536 public boolean containedIn(TypeDecl type) { 537 Object _parameters = type; 538 if(containedIn_TypeDecl_values == null) containedIn_TypeDecl_values = new java.util.HashMap(4); 539 ASTNode$State.CircularValue _value; 540 if(containedIn_TypeDecl_values.containsKey(_parameters)) { 541 Object _o = containedIn_TypeDecl_values.get(_parameters); 542 if(!(_o instanceof ASTNode$State.CircularValue)) { 543 return ((Boolean)_o).booleanValue(); 544 } 545 else 546 _value = (ASTNode$State.CircularValue)_o; 547 } 548 else { 549 _value = new ASTNode$State.CircularValue(); 550 containedIn_TypeDecl_values.put(_parameters, _value); 551 _value.value = Boolean.valueOf(true); 552 } 553 ASTNode$State state = state(); 554 if (!state.IN_CIRCLE) { 555 state.IN_CIRCLE = true; 556 int num = state.boundariesCrossed; 557 boolean isFinal = this.is$Final(); 558 boolean new_containedIn_TypeDecl_value; 559 do { 560 _value.visited = new Integer(state.CIRCLE_INDEX); 561 state.CHANGE = false; 562 new_containedIn_TypeDecl_value = containedIn_compute(type); 563 if (new_containedIn_TypeDecl_value!=((Boolean)_value.value).booleanValue()) { 564 state.CHANGE = true; 565 _value.value = Boolean.valueOf(new_containedIn_TypeDecl_value); 566 } 567 state.CIRCLE_INDEX++; 568 } while (state.CHANGE); 569 if(isFinal && num == state().boundariesCrossed) { 570 containedIn_TypeDecl_values.put(_parameters, new_containedIn_TypeDecl_value); 571 } 572 else { 573 containedIn_TypeDecl_values.remove(_parameters); 574 state.RESET_CYCLE = true; 575 containedIn_compute(type); 576 state.RESET_CYCLE = false; 577 } 578 state.IN_CIRCLE = false; 579 return new_containedIn_TypeDecl_value; 580 } 581 if(!new Integer(state.CIRCLE_INDEX).equals(_value.visited)) { 582 _value.visited = new Integer(state.CIRCLE_INDEX); 583 boolean new_containedIn_TypeDecl_value = containedIn_compute(type); 584 if (state.RESET_CYCLE) { 585 containedIn_TypeDecl_values.remove(_parameters); 586 } 587 else if (new_containedIn_TypeDecl_value!=((Boolean)_value.value).booleanValue()) { 588 state.CHANGE = true; 589 _value.value = new_containedIn_TypeDecl_value; 590 } 591 return new_containedIn_TypeDecl_value; 592 } 593 return ((Boolean)_value.value).booleanValue(); 594 } 595 /** 596 * @apilevel internal 597 */ 598 private boolean containedIn_compute(TypeDecl type) { 599 if(type == this) 600 return true; 601 else if(type instanceof WildcardExtendsType) 602 return typeObject().subtype(((WildcardExtendsType)type).extendsType()); 603 else 604 return false; 605 } 606 protected java.util.Map instanceOf_TypeDecl_values; 607 /** 608 * @attribute syn 609 * @aspect GenericsSubtype 610 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:401 611 */ 612 @SuppressWarnings({"unchecked", "cast"}) 613 public boolean instanceOf(TypeDecl type) { 614 Object _parameters = type; 615 if(instanceOf_TypeDecl_values == null) instanceOf_TypeDecl_values = new java.util.HashMap(4); 616 if(instanceOf_TypeDecl_values.containsKey(_parameters)) { 617 return ((Boolean)instanceOf_TypeDecl_values.get(_parameters)).booleanValue(); 618 } 619 ASTNode$State state = state(); 620 int num = state.boundariesCrossed; 621 boolean isFinal = this.is$Final(); 622 boolean instanceOf_TypeDecl_value = instanceOf_compute(type); 623 if(isFinal && num == state().boundariesCrossed){ instanceOf_TypeDecl_values.put(_parameters, Boolean.valueOf(instanceOf_TypeDecl_value)); } 624 return instanceOf_TypeDecl_value; 625 } 626 /** 627 * @apilevel internal 628 */ 629 private boolean instanceOf_compute(TypeDecl type) { return subtype(type); } 630 /** 631 * @apilevel internal 632 */ 633 protected boolean fieldTypeSignature_computed = false; 634 /** 635 * @apilevel internal 636 */ 637 protected String fieldTypeSignature_value; 638 /** 639 * @attribute syn 640 * @aspect GenericsCodegen 641 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/GenericsCodegen.jrag:446 642 */ 643 @SuppressWarnings({"unchecked", "cast"}) 644 public String fieldTypeSignature() { 645 if(fieldTypeSignature_computed) { 646 return fieldTypeSignature_value; 647 } 648 ASTNode$State state = state(); 649 int num = state.boundariesCrossed; 650 boolean isFinal = this.is$Final(); 651 fieldTypeSignature_value = fieldTypeSignature_compute(); 652 if(isFinal && num == state().boundariesCrossed){ fieldTypeSignature_computed = true; } 653 return fieldTypeSignature_value; 654 } 655 /** 656 * @apilevel internal 657 */ 658 private String fieldTypeSignature_compute() { return "*"; } 659 /** 660 * @apilevel internal 661 */ 662 public ASTNode rewriteTo() { 663 return super.rewriteTo(); 664 } 665 }