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/java8/grammar/ConstructorReference.ast:3 027 * @production ClassReference : {@link ConstructorReference} ::= <span class="component">TypeArgument:{@link Access}*</span>; 028 029 */ 030 public class ClassReference extends ConstructorReference implements Cloneable { 031 /** 032 * @aspect Java8NameCheck 033 * @declaredat /home/jesper/git/extendj/java8/frontend/NameCheck.jrag:530 034 */ 035 public void nameCheck() { 036 for (int i = 0; i < getNumTypeArgument(); i++) { 037 if (getTypeArgument(i) instanceof AbstractWildcard) { 038 error("Wildcard not allowed in constructor reference type argument lists"); 039 break; 040 } 041 } 042 } 043 /** 044 * @aspect Java8PrettyPrint 045 * @declaredat /home/jesper/git/extendj/java8/frontend/PrettyPrint.jadd:69 046 */ 047 public void prettyPrint(PrettyPrinter out) { 048 out.print(getTypeAccess()); 049 out.print("::"); 050 if (hasTypeArgument()) { 051 out.print("<"); 052 out.join(getTypeArguments(), new PrettyPrinter.Joiner() { 053 @Override 054 public void printSeparator(PrettyPrinter out) { 055 out.print(", "); 056 } 057 }); 058 out.print(">"); 059 } 060 out.print("new"); 061 } 062 /** 063 * @declaredat ASTNode:1 064 */ 065 public ClassReference() { 066 super(); 067 } 068 /** 069 * Initializes the child array to the correct size. 070 * Initializes List and Opt nta children. 071 * @apilevel internal 072 * @ast method 073 * @declaredat ASTNode:10 074 */ 075 public void init$Children() { 076 children = new ASTNode[2]; 077 setChild(new List(), 1); 078 } 079 /** 080 * @declaredat ASTNode:14 081 */ 082 public ClassReference(Access p0, List<Access> p1) { 083 setChild(p0, 0); 084 setChild(p1, 1); 085 } 086 /** 087 * @apilevel low-level 088 * @declaredat ASTNode:21 089 */ 090 protected int numChildren() { 091 return 2; 092 } 093 /** 094 * @apilevel internal 095 * @declaredat ASTNode:27 096 */ 097 public boolean mayHaveRewrite() { 098 return false; 099 } 100 /** 101 * @apilevel internal 102 * @declaredat ASTNode:33 103 */ 104 public void flushAttrCache() { 105 super.flushAttrCache(); 106 targetConstructor_FunctionDescriptor_reset(); 107 syntheticInstanceExpr_FunctionDescriptor_reset(); 108 congruentTo_FunctionDescriptor_reset(); 109 potentiallyApplicableConstructors_FunctionDescriptor_reset(); 110 exactCompileTimeDeclaration_reset(); 111 isExact_reset(); 112 potentiallyCompatible_TypeDecl_BodyDecl_reset(); 113 toBlock_reset(); 114 } 115 /** 116 * @apilevel internal 117 * @declaredat ASTNode:47 118 */ 119 public void flushCollectionCache() { 120 super.flushCollectionCache(); 121 } 122 /** 123 * @apilevel internal 124 * @declaredat ASTNode:53 125 */ 126 public void flushRewriteCache() { 127 super.flushRewriteCache(); 128 } 129 /** 130 * @apilevel internal 131 * @declaredat ASTNode:59 132 */ 133 public ClassReference clone() throws CloneNotSupportedException { 134 ClassReference node = (ClassReference) super.clone(); 135 return node; 136 } 137 /** 138 * @apilevel internal 139 * @declaredat ASTNode:66 140 */ 141 public ClassReference copy() { 142 try { 143 ClassReference node = (ClassReference) clone(); 144 node.parent = null; 145 if (children != null) { 146 node.children = (ASTNode[]) children.clone(); 147 } 148 return node; 149 } catch (CloneNotSupportedException e) { 150 throw new Error("Error: clone not supported for " + getClass().getName()); 151 } 152 } 153 /** 154 * Create a deep copy of the AST subtree at this node. 155 * The copy is dangling, i.e. has no parent. 156 * @return dangling copy of the subtree at this node 157 * @apilevel low-level 158 * @deprecated Please use treeCopy or treeCopyNoTransform instead 159 * @declaredat ASTNode:85 160 */ 161 @Deprecated 162 public ClassReference fullCopy() { 163 return treeCopyNoTransform(); 164 } 165 /** 166 * Create a deep copy of the AST subtree at this node. 167 * The copy is dangling, i.e. has no parent. 168 * @return dangling copy of the subtree at this node 169 * @apilevel low-level 170 * @declaredat ASTNode:95 171 */ 172 public ClassReference treeCopyNoTransform() { 173 ClassReference tree = (ClassReference) copy(); 174 if (children != null) { 175 for (int i = 0; i < children.length; ++i) { 176 ASTNode child = (ASTNode) children[i]; 177 if (child != null) { 178 child = child.treeCopyNoTransform(); 179 tree.setChild(child, i); 180 } 181 } 182 } 183 return tree; 184 } 185 /** 186 * Create a deep copy of the AST subtree at this node. 187 * The subtree of this node is traversed to trigger rewrites before copy. 188 * The copy is dangling, i.e. has no parent. 189 * @return dangling copy of the subtree at this node 190 * @apilevel low-level 191 * @declaredat ASTNode:115 192 */ 193 public ClassReference treeCopy() { 194 doFullTraversal(); 195 return treeCopyNoTransform(); 196 } 197 /** 198 * @apilevel internal 199 * @declaredat ASTNode:122 200 */ 201 protected boolean is$Equal(ASTNode node) { 202 return super.is$Equal(node); 203 } 204 /** 205 * Replaces the TypeAccess child. 206 * @param node The new node to replace the TypeAccess child. 207 * @apilevel high-level 208 */ 209 public void setTypeAccess(Access node) { 210 setChild(node, 0); 211 } 212 /** 213 * Retrieves the TypeAccess child. 214 * @return The current node used as the TypeAccess child. 215 * @apilevel high-level 216 */ 217 @ASTNodeAnnotation.Child(name="TypeAccess") 218 public Access getTypeAccess() { 219 return (Access) getChild(0); 220 } 221 /** 222 * Retrieves the TypeAccess child. 223 * <p><em>This method does not invoke AST transformations.</em></p> 224 * @return The current node used as the TypeAccess child. 225 * @apilevel low-level 226 */ 227 public Access getTypeAccessNoTransform() { 228 return (Access) getChildNoTransform(0); 229 } 230 /** 231 * Replaces the TypeArgument list. 232 * @param list The new list node to be used as the TypeArgument list. 233 * @apilevel high-level 234 */ 235 public void setTypeArgumentList(List<Access> list) { 236 setChild(list, 1); 237 } 238 /** 239 * Retrieves the number of children in the TypeArgument list. 240 * @return Number of children in the TypeArgument list. 241 * @apilevel high-level 242 */ 243 public int getNumTypeArgument() { 244 return getTypeArgumentList().getNumChild(); 245 } 246 /** 247 * Retrieves the number of children in the TypeArgument list. 248 * Calling this method will not trigger rewrites. 249 * @return Number of children in the TypeArgument list. 250 * @apilevel low-level 251 */ 252 public int getNumTypeArgumentNoTransform() { 253 return getTypeArgumentListNoTransform().getNumChildNoTransform(); 254 } 255 /** 256 * Retrieves the element at index {@code i} in the TypeArgument list. 257 * @param i Index of the element to return. 258 * @return The element at position {@code i} in the TypeArgument list. 259 * @apilevel high-level 260 */ 261 public Access getTypeArgument(int i) { 262 return (Access) getTypeArgumentList().getChild(i); 263 } 264 /** 265 * Check whether the TypeArgument list has any children. 266 * @return {@code true} if it has at least one child, {@code false} otherwise. 267 * @apilevel high-level 268 */ 269 public boolean hasTypeArgument() { 270 return getTypeArgumentList().getNumChild() != 0; 271 } 272 /** 273 * Append an element to the TypeArgument list. 274 * @param node The element to append to the TypeArgument list. 275 * @apilevel high-level 276 */ 277 public void addTypeArgument(Access node) { 278 List<Access> list = (parent == null) ? getTypeArgumentListNoTransform() : getTypeArgumentList(); 279 list.addChild(node); 280 } 281 /** 282 * @apilevel low-level 283 */ 284 public void addTypeArgumentNoTransform(Access node) { 285 List<Access> list = getTypeArgumentListNoTransform(); 286 list.addChild(node); 287 } 288 /** 289 * Replaces the TypeArgument list element at index {@code i} with the new node {@code node}. 290 * @param node The new node to replace the old list element. 291 * @param i The list index of the node to be replaced. 292 * @apilevel high-level 293 */ 294 public void setTypeArgument(Access node, int i) { 295 List<Access> list = getTypeArgumentList(); 296 list.setChild(node, i); 297 } 298 /** 299 * Retrieves the TypeArgument list. 300 * @return The node representing the TypeArgument list. 301 * @apilevel high-level 302 */ 303 @ASTNodeAnnotation.ListChild(name="TypeArgument") 304 public List<Access> getTypeArgumentList() { 305 List<Access> list = (List<Access>) getChild(1); 306 return list; 307 } 308 /** 309 * Retrieves the TypeArgument list. 310 * <p><em>This method does not invoke AST transformations.</em></p> 311 * @return The node representing the TypeArgument list. 312 * @apilevel low-level 313 */ 314 public List<Access> getTypeArgumentListNoTransform() { 315 return (List<Access>) getChildNoTransform(1); 316 } 317 /** 318 * Retrieves the TypeArgument list. 319 * @return The node representing the TypeArgument list. 320 * @apilevel high-level 321 */ 322 public List<Access> getTypeArguments() { 323 return getTypeArgumentList(); 324 } 325 /** 326 * Retrieves the TypeArgument list. 327 * <p><em>This method does not invoke AST transformations.</em></p> 328 * @return The node representing the TypeArgument list. 329 * @apilevel low-level 330 */ 331 public List<Access> getTypeArgumentsNoTransform() { 332 return getTypeArgumentListNoTransform(); 333 } 334 /** 335 * @apilevel internal 336 */ 337 protected java.util.Map targetConstructor_FunctionDescriptor_values; 338 /** 339 * @apilevel internal 340 */ 341 private void targetConstructor_FunctionDescriptor_reset() { 342 targetConstructor_FunctionDescriptor_values = null; 343 } 344 /** 345 * @attribute syn 346 * @aspect ConstructorReference 347 * @declaredat /home/jesper/git/extendj/java8/frontend/ConstructorReference.jrag:31 348 */ 349 @ASTNodeAnnotation.Attribute 350 public ConstructorDecl targetConstructor(FunctionDescriptor f) { 351 Object _parameters = f; 352 if (targetConstructor_FunctionDescriptor_values == null) targetConstructor_FunctionDescriptor_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 353 ASTNode$State state = state(); 354 if (targetConstructor_FunctionDescriptor_values.containsKey(_parameters)) { 355 return (ConstructorDecl) targetConstructor_FunctionDescriptor_values.get(_parameters); 356 } 357 boolean intermediate = state.INTERMEDIATE_VALUE; 358 state.INTERMEDIATE_VALUE = false; 359 int num = state.boundariesCrossed; 360 boolean isFinal = this.is$Final(); 361 ConstructorDecl targetConstructor_FunctionDescriptor_value = syntheticInstanceExpr(f).decl(); 362 if (isFinal && num == state().boundariesCrossed) { 363 targetConstructor_FunctionDescriptor_values.put(_parameters, targetConstructor_FunctionDescriptor_value); 364 } else { 365 } 366 state.INTERMEDIATE_VALUE |= intermediate; 367 368 return targetConstructor_FunctionDescriptor_value; 369 } 370 /** 371 * @apilevel internal 372 */ 373 protected List syntheticInstanceExpr_FunctionDescriptor_list; 374 /** 375 * @apilevel internal 376 */ 377 protected java.util.Map syntheticInstanceExpr_FunctionDescriptor_values; 378 /** 379 * @apilevel internal 380 */ 381 private void syntheticInstanceExpr_FunctionDescriptor_reset() { 382 syntheticInstanceExpr_FunctionDescriptor_values = null; 383 syntheticInstanceExpr_FunctionDescriptor_list = null; 384 } 385 /** 386 * @attribute syn 387 * @aspect ConstructorReference 388 * @declaredat /home/jesper/git/extendj/java8/frontend/ConstructorReference.jrag:34 389 */ 390 @ASTNodeAnnotation.Attribute 391 public ClassInstanceExpr syntheticInstanceExpr(FunctionDescriptor f) { 392 Object _parameters = f; 393 if (syntheticInstanceExpr_FunctionDescriptor_values == null) syntheticInstanceExpr_FunctionDescriptor_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 394 ASTNode$State state = state(); 395 if (syntheticInstanceExpr_FunctionDescriptor_values.containsKey(_parameters)) { 396 return (ClassInstanceExpr) syntheticInstanceExpr_FunctionDescriptor_values.get(_parameters); 397 } 398 boolean intermediate = state.INTERMEDIATE_VALUE; 399 state.INTERMEDIATE_VALUE = false; 400 int num = state.boundariesCrossed; 401 boolean isFinal = this.is$Final(); 402 ClassInstanceExpr syntheticInstanceExpr_FunctionDescriptor_value = syntheticInstanceExpr_compute(f); 403 if (syntheticInstanceExpr_FunctionDescriptor_list == null) { 404 syntheticInstanceExpr_FunctionDescriptor_list = new List(); 405 syntheticInstanceExpr_FunctionDescriptor_list.is$Final = true; 406 syntheticInstanceExpr_FunctionDescriptor_list.setParent(this); 407 } 408 syntheticInstanceExpr_FunctionDescriptor_list.add(syntheticInstanceExpr_FunctionDescriptor_value); 409 if (syntheticInstanceExpr_FunctionDescriptor_value != null) { 410 syntheticInstanceExpr_FunctionDescriptor_value = (ClassInstanceExpr) syntheticInstanceExpr_FunctionDescriptor_list.getChild(syntheticInstanceExpr_FunctionDescriptor_list.numChildren-1); 411 syntheticInstanceExpr_FunctionDescriptor_value.is$Final = true; 412 } 413 if (true) { 414 syntheticInstanceExpr_FunctionDescriptor_values.put(_parameters, syntheticInstanceExpr_FunctionDescriptor_value); 415 } else { 416 } 417 state.INTERMEDIATE_VALUE |= intermediate; 418 419 return syntheticInstanceExpr_FunctionDescriptor_value; 420 } 421 /** 422 * @apilevel internal 423 */ 424 private ClassInstanceExpr syntheticInstanceExpr_compute(FunctionDescriptor f) { 425 List<Expr> arguments = new List<Expr>(); 426 for (int i = 0; i < f.method.getNumParameter(); i++) { 427 TypeDecl argumentType = f.method.getParameter(i).type(); 428 arguments.add(new SyntheticTypeAccess(argumentType)); 429 } 430 431 ClassInstanceExpr instanceExpr = null; 432 if (hasTypeArgument()) { 433 instanceExpr = new ParConstructorReferenceAccess( 434 (Access) getTypeAccess().treeCopyNoTransform(), arguments, 435 new Opt(), (List<Access>)getTypeArgumentList().treeCopyNoTransform(), f); 436 } else { 437 // Must check for raw reference type, and in that case infer using diamond (JLS 15.13.1) 438 boolean checkDiamond = true; 439 if (getTypeAccess().type().hostType() != null && !getTypeAccess().type().isStatic() 440 && getTypeAccess().type().hostType().isRawType()) { 441 checkDiamond = false; 442 } 443 if (getTypeAccess().type().isRawType() && checkDiamond) { 444 DiamondAccess diamond = new DiamondAccess((Access)getTypeAccess().treeCopyNoTransform()); 445 instanceExpr = new ConstructorReferenceAccess(diamond, arguments, f); 446 } else { 447 instanceExpr = new ConstructorReferenceAccess( 448 (Access) getTypeAccess().treeCopyNoTransform(), arguments, f); 449 } 450 } 451 return instanceExpr; 452 } 453 /** 454 * @apilevel internal 455 */ 456 protected java.util.Map congruentTo_FunctionDescriptor_values; 457 /** 458 * @apilevel internal 459 */ 460 private void congruentTo_FunctionDescriptor_reset() { 461 congruentTo_FunctionDescriptor_values = null; 462 } 463 /** 464 * @attribute syn 465 * @aspect ConstructorReference 466 * @declaredat /home/jesper/git/extendj/java8/frontend/ConstructorReference.jrag:68 467 */ 468 @ASTNodeAnnotation.Attribute 469 public boolean congruentTo(FunctionDescriptor f) { 470 Object _parameters = f; 471 if (congruentTo_FunctionDescriptor_values == null) congruentTo_FunctionDescriptor_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 472 ASTNode$State state = state(); 473 if (congruentTo_FunctionDescriptor_values.containsKey(_parameters)) { 474 return (Boolean) congruentTo_FunctionDescriptor_values.get(_parameters); 475 } 476 boolean intermediate = state.INTERMEDIATE_VALUE; 477 state.INTERMEDIATE_VALUE = false; 478 int num = state.boundariesCrossed; 479 boolean isFinal = this.is$Final(); 480 boolean congruentTo_FunctionDescriptor_value = congruentTo_compute(f); 481 if (isFinal && num == state().boundariesCrossed) { 482 congruentTo_FunctionDescriptor_values.put(_parameters, congruentTo_FunctionDescriptor_value); 483 } else { 484 } 485 state.INTERMEDIATE_VALUE |= intermediate; 486 487 return congruentTo_FunctionDescriptor_value; 488 } 489 /** 490 * @apilevel internal 491 */ 492 private boolean congruentTo_compute(FunctionDescriptor f) { 493 ConstructorDecl decl = targetConstructor(f); 494 if (unknownConstructor() == decl) { 495 return false; 496 } 497 if (!f.method.type().isVoid()) { 498 TypeDecl returnType = syntheticInstanceExpr(f).type(); 499 if (!returnType.assignConversionTo(f.method.type(), null)) { 500 return false; 501 } 502 } 503 return true; 504 } 505 /** 506 * @apilevel internal 507 */ 508 protected java.util.Map potentiallyApplicableConstructors_FunctionDescriptor_values; 509 /** 510 * @apilevel internal 511 */ 512 private void potentiallyApplicableConstructors_FunctionDescriptor_reset() { 513 potentiallyApplicableConstructors_FunctionDescriptor_values = null; 514 } 515 /** 516 * @attribute syn 517 * @aspect ConstructorReference 518 * @declaredat /home/jesper/git/extendj/java8/frontend/ConstructorReference.jrag:100 519 */ 520 @ASTNodeAnnotation.Attribute 521 public ArrayList<ConstructorDecl> potentiallyApplicableConstructors(FunctionDescriptor f) { 522 Object _parameters = f; 523 if (potentiallyApplicableConstructors_FunctionDescriptor_values == null) potentiallyApplicableConstructors_FunctionDescriptor_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 524 ASTNode$State state = state(); 525 if (potentiallyApplicableConstructors_FunctionDescriptor_values.containsKey(_parameters)) { 526 return (ArrayList<ConstructorDecl>) potentiallyApplicableConstructors_FunctionDescriptor_values.get(_parameters); 527 } 528 boolean intermediate = state.INTERMEDIATE_VALUE; 529 state.INTERMEDIATE_VALUE = false; 530 int num = state.boundariesCrossed; 531 boolean isFinal = this.is$Final(); 532 ArrayList<ConstructorDecl> potentiallyApplicableConstructors_FunctionDescriptor_value = potentiallyApplicableConstructors_compute(f); 533 if (isFinal && num == state().boundariesCrossed) { 534 potentiallyApplicableConstructors_FunctionDescriptor_values.put(_parameters, potentiallyApplicableConstructors_FunctionDescriptor_value); 535 } else { 536 } 537 state.INTERMEDIATE_VALUE |= intermediate; 538 539 return potentiallyApplicableConstructors_FunctionDescriptor_value; 540 } 541 /** 542 * @apilevel internal 543 */ 544 private ArrayList<ConstructorDecl> potentiallyApplicableConstructors_compute(FunctionDescriptor f) { 545 TypeDecl classType = syntheticInstanceExpr(f).type(); 546 Collection<ConstructorDecl> col = classType.constructors(); 547 ArrayList<ConstructorDecl> applicable = new ArrayList<ConstructorDecl>(); 548 for (ConstructorDecl decl : col) { 549 if (!decl.accessibleFrom(hostType())) { 550 continue; 551 } 552 if (!(decl.arity() == f.method.arity())) { 553 continue; 554 } 555 if (hasTypeArgument()) { 556 if (!decl.isGeneric()) { 557 continue; 558 } 559 GenericConstructorDecl genDecl = decl.genericDecl(); 560 if (!(getNumTypeArgument() == genDecl.getNumTypeParameter())) { 561 continue; 562 } 563 } 564 applicable.add(decl); 565 } 566 return applicable; 567 } 568 /** 569 * @apilevel internal 570 */ 571 protected boolean exactCompileTimeDeclaration_computed = false; 572 /** 573 * @apilevel internal 574 */ 575 protected ConstructorDecl exactCompileTimeDeclaration_value; 576 /** 577 * @apilevel internal 578 */ 579 private void exactCompileTimeDeclaration_reset() { 580 exactCompileTimeDeclaration_computed = false; 581 exactCompileTimeDeclaration_value = null; 582 } 583 /** 584 * @attribute syn 585 * @aspect ConstructorReference 586 * @declaredat /home/jesper/git/extendj/java8/frontend/ConstructorReference.jrag:129 587 */ 588 @ASTNodeAnnotation.Attribute 589 public ConstructorDecl exactCompileTimeDeclaration() { 590 ASTNode$State state = state(); 591 if (exactCompileTimeDeclaration_computed) { 592 return exactCompileTimeDeclaration_value; 593 } 594 boolean intermediate = state.INTERMEDIATE_VALUE; 595 state.INTERMEDIATE_VALUE = false; 596 int num = state.boundariesCrossed; 597 boolean isFinal = this.is$Final(); 598 exactCompileTimeDeclaration_value = exactCompileTimeDeclaration_compute(); 599 if (isFinal && num == state().boundariesCrossed) { 600 exactCompileTimeDeclaration_computed = true; 601 } else { 602 } 603 state.INTERMEDIATE_VALUE |= intermediate; 604 605 return exactCompileTimeDeclaration_value; 606 } 607 /** 608 * @apilevel internal 609 */ 610 private ConstructorDecl exactCompileTimeDeclaration_compute() { 611 if (getTypeAccess().type().isRawType()) { 612 if (getTypeAccess().type().hostType() == null || getTypeAccess().type().isStatic() 613 || getTypeAccess().type().hostType().isRawType()) { 614 return unknownConstructor(); 615 } 616 } 617 TypeDecl classType = getTypeAccess().type(); 618 Collection<ConstructorDecl> col = classType.constructors(); 619 ArrayList<ConstructorDecl> applicable = new ArrayList<ConstructorDecl>(); 620 int foundCompatible = 0; 621 ConstructorDecl latestDecl = null; 622 623 for (ConstructorDecl decl : col) { 624 if (decl.accessibleFrom(hostType())) { 625 foundCompatible++; 626 latestDecl = decl; 627 } 628 } 629 if (foundCompatible != 1) { 630 return unknownConstructor(); 631 } 632 if (latestDecl.isVariableArity()) { 633 return unknownConstructor(); 634 } 635 if (latestDecl.isGeneric()) { 636 GenericConstructorDecl genericDecl = latestDecl.genericDecl(); 637 if (getNumTypeArgument() == genericDecl.getNumTypeParameter()) { 638 return latestDecl; 639 } else { 640 return unknownConstructor(); 641 } 642 } 643 return latestDecl; 644 } 645 /** 646 * @apilevel internal 647 */ 648 protected boolean isExact_computed = false; 649 /** 650 * @apilevel internal 651 */ 652 protected boolean isExact_value; 653 /** 654 * @apilevel internal 655 */ 656 private void isExact_reset() { 657 isExact_computed = false; 658 } 659 /** 660 * @attribute syn 661 * @aspect ConstructorReference 662 * @declaredat /home/jesper/git/extendj/java8/frontend/ConstructorReference.jrag:127 663 */ 664 @ASTNodeAnnotation.Attribute 665 public boolean isExact() { 666 ASTNode$State state = state(); 667 if (isExact_computed) { 668 return isExact_value; 669 } 670 boolean intermediate = state.INTERMEDIATE_VALUE; 671 state.INTERMEDIATE_VALUE = false; 672 int num = state.boundariesCrossed; 673 boolean isFinal = this.is$Final(); 674 isExact_value = exactCompileTimeDeclaration() != unknownConstructor(); 675 if (isFinal && num == state().boundariesCrossed) { 676 isExact_computed = true; 677 } else { 678 } 679 state.INTERMEDIATE_VALUE |= intermediate; 680 681 return isExact_value; 682 } 683 /** 684 * @apilevel internal 685 */ 686 protected java.util.Map potentiallyCompatible_TypeDecl_BodyDecl_values; 687 /** 688 * @apilevel internal 689 */ 690 private void potentiallyCompatible_TypeDecl_BodyDecl_reset() { 691 potentiallyCompatible_TypeDecl_BodyDecl_values = null; 692 } 693 /** 694 * @attribute syn 695 * @aspect MethodSignature18 696 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodSignature.jrag:466 697 */ 698 @ASTNodeAnnotation.Attribute 699 public boolean potentiallyCompatible(TypeDecl type, BodyDecl candidateDecl) { 700 java.util.List _parameters = new java.util.ArrayList(2); 701 _parameters.add(type); 702 _parameters.add(candidateDecl); 703 if (potentiallyCompatible_TypeDecl_BodyDecl_values == null) potentiallyCompatible_TypeDecl_BodyDecl_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 704 ASTNode$State state = state(); 705 if (potentiallyCompatible_TypeDecl_BodyDecl_values.containsKey(_parameters)) { 706 return (Boolean) potentiallyCompatible_TypeDecl_BodyDecl_values.get(_parameters); 707 } 708 boolean intermediate = state.INTERMEDIATE_VALUE; 709 state.INTERMEDIATE_VALUE = false; 710 int num = state.boundariesCrossed; 711 boolean isFinal = this.is$Final(); 712 boolean potentiallyCompatible_TypeDecl_BodyDecl_value = potentiallyCompatible_compute(type, candidateDecl); 713 if (isFinal && num == state().boundariesCrossed) { 714 potentiallyCompatible_TypeDecl_BodyDecl_values.put(_parameters, potentiallyCompatible_TypeDecl_BodyDecl_value); 715 } else { 716 } 717 state.INTERMEDIATE_VALUE |= intermediate; 718 719 return potentiallyCompatible_TypeDecl_BodyDecl_value; 720 } 721 /** 722 * @apilevel internal 723 */ 724 private boolean potentiallyCompatible_compute(TypeDecl type, BodyDecl candidateDecl) { 725 if (super.potentiallyCompatible(type, candidateDecl) && type.isTypeVariable()) { 726 return true; 727 } else if (!super.potentiallyCompatible(type, candidateDecl)) { 728 return false; 729 } 730 731 InterfaceDecl iDecl = (InterfaceDecl) type; 732 FunctionDescriptor f = iDecl.functionDescriptor(); 733 734 boolean foundMethod = false; 735 for (ConstructorDecl decl : potentiallyApplicableConstructors(f)) { 736 if (f.method.arity() == decl.arity()) { 737 foundMethod = true; 738 break; 739 } 740 } 741 return foundMethod; 742 } 743 /** 744 * @apilevel internal 745 */ 746 protected boolean toBlock_computed = false; 747 /** 748 * @apilevel internal 749 */ 750 protected Block toBlock_value; 751 /** 752 * @apilevel internal 753 */ 754 private void toBlock_reset() { 755 toBlock_computed = false; 756 toBlock_value = null; 757 } 758 /** 759 * @attribute syn 760 * @aspect ConstructorReferenceToClass 761 * @declaredat /home/jesper/git/extendj/java8/backend/ConstructorReferenceToClass.jrag:85 762 */ 763 @ASTNodeAnnotation.Attribute 764 public Block toBlock() { 765 ASTNode$State state = state(); 766 if (toBlock_computed) { 767 return toBlock_value; 768 } 769 boolean intermediate = state.INTERMEDIATE_VALUE; 770 state.INTERMEDIATE_VALUE = false; 771 int num = state.boundariesCrossed; 772 boolean isFinal = this.is$Final(); 773 toBlock_value = toBlock_compute(); 774 if (isFinal && num == state().boundariesCrossed) { 775 toBlock_computed = true; 776 } else { 777 } 778 state.INTERMEDIATE_VALUE |= intermediate; 779 780 return toBlock_value; 781 } 782 /** 783 * @apilevel internal 784 */ 785 private Block toBlock_compute() { 786 List<Expr> arguments = new List<Expr>(); 787 for (int i = 0; i < targetInterface().functionDescriptor().method.getNumParameter(); i++) { 788 String paramName = targetInterface().functionDescriptor().method.getParameter(i).name(); 789 arguments.add(new VarAccess(paramName)); 790 } 791 792 ClassInstanceExpr instanceExpr = null; 793 if (hasTypeArgument()) { 794 instanceExpr = new ParClassInstanceExpr((Access) getTypeAccess().treeCopyNoTransform(), arguments, 795 new Opt(), (List<Access>)getTypeArgumentList().treeCopyNoTransform()); 796 } else { 797 if (getTypeAccess().type().isRawType()) { 798 DiamondAccess diamond = new DiamondAccess((Access) getTypeAccess().treeCopyNoTransform()); 799 instanceExpr = new ClassInstanceExpr(diamond, arguments); 800 } else { 801 instanceExpr = new ClassInstanceExpr((Access) getTypeAccess().treeCopyNoTransform(), arguments); 802 } 803 } 804 Stmt blockStmt = null; 805 if (targetInterface().functionDescriptor().method.type().isVoid()) { 806 blockStmt = new ExprStmt(instanceExpr); 807 } else { 808 blockStmt = new ReturnStmt(instanceExpr); 809 } 810 List<Stmt> stmtList = new List<Stmt>(); 811 stmtList.add(blockStmt); 812 return new Block(stmtList); 813 814 } 815 /** 816 * @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:36 817 * @apilevel internal 818 */ 819 public NameType Define_nameType(ASTNode caller, ASTNode child) { 820 if (caller == getTypeArgumentListNoTransform()) { 821 // @declaredat /home/jesper/git/extendj/java8/frontend/ConstructorReference.jrag:65 822 int childIndex = caller.getIndexOfChild(child); 823 return NameType.TYPE_NAME; 824 } 825 else { 826 return super.Define_nameType(caller, child); 827 } 828 } 829 protected boolean canDefine_nameType(ASTNode caller, ASTNode child) { 830 return true; 831 } 832 /** 833 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:30 834 * @apilevel internal 835 */ 836 public TypeDecl Define_targetType(ASTNode caller, ASTNode child) { 837 if (caller == toClass_value) { 838 // @declaredat /home/jesper/git/extendj/java8/backend/ToClassInherited.jrag:44 839 { 840 return targetInterface().functionDescriptor().method.type(); 841 } 842 } 843 else { 844 return getParent().Define_targetType(this, caller); 845 } 846 } 847 protected boolean canDefine_targetType(ASTNode caller, ASTNode child) { 848 return true; 849 } 850 /** 851 * @apilevel internal 852 */ 853 public ASTNode rewriteTo() { 854 return super.rewriteTo(); 855 } 856 }