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/MethodReference.ast:4 027 * @production TypeMethodReference : {@link MethodReference} ::= <span class="component">TypeAccess:{@link Access}</span>; 028 029 */ 030 public class TypeMethodReference extends MethodReference implements Cloneable { 031 /** 032 * @aspect Java8PrettyPrint 033 * @declaredat /home/jesper/git/extendj/java8/frontend/PrettyPrint.jadd:103 034 */ 035 public void prettyPrint(PrettyPrinter out) { 036 out.print(getTypeAccess()); 037 out.print("::"); 038 if (hasTypeArgument()) { 039 out.print("<"); 040 out.join(getTypeArguments(), new PrettyPrinter.Joiner() { 041 @Override 042 public void printSeparator(PrettyPrinter out) { 043 out.print(", "); 044 } 045 }); 046 out.print(">"); 047 } 048 out.print(name()); 049 } 050 /** 051 * @aspect Java8CreateBCode 052 * @declaredat /home/jesper/git/extendj/java8/backend/CreateBCode.jrag:37 053 */ 054 public void createBCode(CodeGeneration gen) { 055 toClass().createBCode(gen); 056 } 057 /** 058 * @aspect Transformations 059 * @declaredat /home/jesper/git/extendj/java8/backend/Transformations.jrag:37 060 */ 061 public void transformation() { 062 toClass().transformation(); 063 } 064 /** 065 * @declaredat ASTNode:1 066 */ 067 public TypeMethodReference() { 068 super(); 069 } 070 /** 071 * Initializes the child array to the correct size. 072 * Initializes List and Opt nta children. 073 * @apilevel internal 074 * @ast method 075 * @declaredat ASTNode:10 076 */ 077 public void init$Children() { 078 children = new ASTNode[2]; 079 setChild(new List(), 0); 080 } 081 /** 082 * @declaredat ASTNode:14 083 */ 084 public TypeMethodReference(List<Access> p0, String p1, Access p2) { 085 setChild(p0, 0); 086 setID(p1); 087 setChild(p2, 1); 088 } 089 /** 090 * @declaredat ASTNode:19 091 */ 092 public TypeMethodReference(List<Access> p0, beaver.Symbol p1, Access p2) { 093 setChild(p0, 0); 094 setID(p1); 095 setChild(p2, 1); 096 } 097 /** 098 * @apilevel low-level 099 * @declaredat ASTNode:27 100 */ 101 protected int numChildren() { 102 return 2; 103 } 104 /** 105 * @apilevel internal 106 * @declaredat ASTNode:33 107 */ 108 public boolean mayHaveRewrite() { 109 return false; 110 } 111 /** 112 * @apilevel internal 113 * @declaredat ASTNode:39 114 */ 115 public void flushAttrCache() { 116 super.flushAttrCache(); 117 targetStaticMethod_FunctionDescriptor_reset(); 118 targetInstanceMethod_FunctionDescriptor_reset(); 119 validStaticMethod_FunctionDescriptor_reset(); 120 validInstanceMethod_FunctionDescriptor_reset(); 121 inferredReferenceType_FunctionDescriptor_reset(); 122 syntheticStaticAccess_FunctionDescriptor_reset(); 123 syntheticStaticMethodAccess_FunctionDescriptor_reset(); 124 syntheticInstanceAccess_FunctionDescriptor_reset(); 125 syntheticInstanceMethodAccess_FunctionDescriptor_reset(); 126 congruentTo_FunctionDescriptor_reset(); 127 potentiallyApplicableMethods_FunctionDescriptor_reset(); 128 exactCompileTimeDeclaration_reset(); 129 potentiallyCompatible_TypeDecl_BodyDecl_reset(); 130 toClass_reset(); 131 toBlock_reset(); 132 } 133 /** 134 * @apilevel internal 135 * @declaredat ASTNode:60 136 */ 137 public void flushCollectionCache() { 138 super.flushCollectionCache(); 139 } 140 /** 141 * @apilevel internal 142 * @declaredat ASTNode:66 143 */ 144 public void flushRewriteCache() { 145 super.flushRewriteCache(); 146 } 147 /** 148 * @apilevel internal 149 * @declaredat ASTNode:72 150 */ 151 public TypeMethodReference clone() throws CloneNotSupportedException { 152 TypeMethodReference node = (TypeMethodReference) super.clone(); 153 return node; 154 } 155 /** 156 * @apilevel internal 157 * @declaredat ASTNode:79 158 */ 159 public TypeMethodReference copy() { 160 try { 161 TypeMethodReference node = (TypeMethodReference) clone(); 162 node.parent = null; 163 if (children != null) { 164 node.children = (ASTNode[]) children.clone(); 165 } 166 return node; 167 } catch (CloneNotSupportedException e) { 168 throw new Error("Error: clone not supported for " + getClass().getName()); 169 } 170 } 171 /** 172 * Create a deep copy of the AST subtree at this node. 173 * The copy is dangling, i.e. has no parent. 174 * @return dangling copy of the subtree at this node 175 * @apilevel low-level 176 * @deprecated Please use treeCopy or treeCopyNoTransform instead 177 * @declaredat ASTNode:98 178 */ 179 @Deprecated 180 public TypeMethodReference fullCopy() { 181 return treeCopyNoTransform(); 182 } 183 /** 184 * Create a deep copy of the AST subtree at this node. 185 * The copy is dangling, i.e. has no parent. 186 * @return dangling copy of the subtree at this node 187 * @apilevel low-level 188 * @declaredat ASTNode:108 189 */ 190 public TypeMethodReference treeCopyNoTransform() { 191 TypeMethodReference tree = (TypeMethodReference) copy(); 192 if (children != null) { 193 for (int i = 0; i < children.length; ++i) { 194 ASTNode child = (ASTNode) children[i]; 195 if (child != null) { 196 child = child.treeCopyNoTransform(); 197 tree.setChild(child, i); 198 } 199 } 200 } 201 return tree; 202 } 203 /** 204 * Create a deep copy of the AST subtree at this node. 205 * The subtree of this node is traversed to trigger rewrites before copy. 206 * The copy is dangling, i.e. has no parent. 207 * @return dangling copy of the subtree at this node 208 * @apilevel low-level 209 * @declaredat ASTNode:128 210 */ 211 public TypeMethodReference treeCopy() { 212 doFullTraversal(); 213 return treeCopyNoTransform(); 214 } 215 /** 216 * @apilevel internal 217 * @declaredat ASTNode:135 218 */ 219 protected boolean is$Equal(ASTNode node) { 220 return super.is$Equal(node) && (tokenString_ID == ((TypeMethodReference)node).tokenString_ID); 221 } 222 /** 223 * Replaces the TypeArgument list. 224 * @param list The new list node to be used as the TypeArgument list. 225 * @apilevel high-level 226 */ 227 public void setTypeArgumentList(List<Access> list) { 228 setChild(list, 0); 229 } 230 /** 231 * Retrieves the number of children in the TypeArgument list. 232 * @return Number of children in the TypeArgument list. 233 * @apilevel high-level 234 */ 235 public int getNumTypeArgument() { 236 return getTypeArgumentList().getNumChild(); 237 } 238 /** 239 * Retrieves the number of children in the TypeArgument list. 240 * Calling this method will not trigger rewrites. 241 * @return Number of children in the TypeArgument list. 242 * @apilevel low-level 243 */ 244 public int getNumTypeArgumentNoTransform() { 245 return getTypeArgumentListNoTransform().getNumChildNoTransform(); 246 } 247 /** 248 * Retrieves the element at index {@code i} in the TypeArgument list. 249 * @param i Index of the element to return. 250 * @return The element at position {@code i} in the TypeArgument list. 251 * @apilevel high-level 252 */ 253 public Access getTypeArgument(int i) { 254 return (Access) getTypeArgumentList().getChild(i); 255 } 256 /** 257 * Check whether the TypeArgument list has any children. 258 * @return {@code true} if it has at least one child, {@code false} otherwise. 259 * @apilevel high-level 260 */ 261 public boolean hasTypeArgument() { 262 return getTypeArgumentList().getNumChild() != 0; 263 } 264 /** 265 * Append an element to the TypeArgument list. 266 * @param node The element to append to the TypeArgument list. 267 * @apilevel high-level 268 */ 269 public void addTypeArgument(Access node) { 270 List<Access> list = (parent == null) ? getTypeArgumentListNoTransform() : getTypeArgumentList(); 271 list.addChild(node); 272 } 273 /** 274 * @apilevel low-level 275 */ 276 public void addTypeArgumentNoTransform(Access node) { 277 List<Access> list = getTypeArgumentListNoTransform(); 278 list.addChild(node); 279 } 280 /** 281 * Replaces the TypeArgument list element at index {@code i} with the new node {@code node}. 282 * @param node The new node to replace the old list element. 283 * @param i The list index of the node to be replaced. 284 * @apilevel high-level 285 */ 286 public void setTypeArgument(Access node, int i) { 287 List<Access> list = getTypeArgumentList(); 288 list.setChild(node, i); 289 } 290 /** 291 * Retrieves the TypeArgument list. 292 * @return The node representing the TypeArgument list. 293 * @apilevel high-level 294 */ 295 @ASTNodeAnnotation.ListChild(name="TypeArgument") 296 public List<Access> getTypeArgumentList() { 297 List<Access> list = (List<Access>) getChild(0); 298 return list; 299 } 300 /** 301 * Retrieves the TypeArgument list. 302 * <p><em>This method does not invoke AST transformations.</em></p> 303 * @return The node representing the TypeArgument list. 304 * @apilevel low-level 305 */ 306 public List<Access> getTypeArgumentListNoTransform() { 307 return (List<Access>) getChildNoTransform(0); 308 } 309 /** 310 * Retrieves the TypeArgument list. 311 * @return The node representing the TypeArgument list. 312 * @apilevel high-level 313 */ 314 public List<Access> getTypeArguments() { 315 return getTypeArgumentList(); 316 } 317 /** 318 * Retrieves the TypeArgument list. 319 * <p><em>This method does not invoke AST transformations.</em></p> 320 * @return The node representing the TypeArgument list. 321 * @apilevel low-level 322 */ 323 public List<Access> getTypeArgumentsNoTransform() { 324 return getTypeArgumentListNoTransform(); 325 } 326 /** 327 * Replaces the lexeme ID. 328 * @param value The new value for the lexeme ID. 329 * @apilevel high-level 330 */ 331 public void setID(String value) { 332 tokenString_ID = value; 333 } 334 /** 335 * JastAdd-internal setter for lexeme ID using the Beaver parser. 336 * @param symbol Symbol containing the new value for the lexeme ID 337 * @apilevel internal 338 */ 339 public void setID(beaver.Symbol symbol) { 340 if (symbol.value != null && !(symbol.value instanceof String)) 341 throw new UnsupportedOperationException("setID is only valid for String lexemes"); 342 tokenString_ID = (String)symbol.value; 343 IDstart = symbol.getStart(); 344 IDend = symbol.getEnd(); 345 } 346 /** 347 * Retrieves the value for the lexeme ID. 348 * @return The value for the lexeme ID. 349 * @apilevel high-level 350 */ 351 @ASTNodeAnnotation.Token(name="ID") 352 public String getID() { 353 return tokenString_ID != null ? tokenString_ID : ""; 354 } 355 /** 356 * Replaces the TypeAccess child. 357 * @param node The new node to replace the TypeAccess child. 358 * @apilevel high-level 359 */ 360 public void setTypeAccess(Access node) { 361 setChild(node, 1); 362 } 363 /** 364 * Retrieves the TypeAccess child. 365 * @return The current node used as the TypeAccess child. 366 * @apilevel high-level 367 */ 368 @ASTNodeAnnotation.Child(name="TypeAccess") 369 public Access getTypeAccess() { 370 return (Access) getChild(1); 371 } 372 /** 373 * Retrieves the TypeAccess child. 374 * <p><em>This method does not invoke AST transformations.</em></p> 375 * @return The current node used as the TypeAccess child. 376 * @apilevel low-level 377 */ 378 public Access getTypeAccessNoTransform() { 379 return (Access) getChildNoTransform(1); 380 } 381 /** 382 * @apilevel internal 383 */ 384 protected java.util.Map targetStaticMethod_FunctionDescriptor_values; 385 /** 386 * @apilevel internal 387 */ 388 private void targetStaticMethod_FunctionDescriptor_reset() { 389 targetStaticMethod_FunctionDescriptor_values = null; 390 } 391 /** 392 * @attribute syn 393 * @aspect MethodReference 394 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:66 395 */ 396 @ASTNodeAnnotation.Attribute 397 public MethodDecl targetStaticMethod(FunctionDescriptor f) { 398 Object _parameters = f; 399 if (targetStaticMethod_FunctionDescriptor_values == null) targetStaticMethod_FunctionDescriptor_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 400 ASTNode$State state = state(); 401 if (targetStaticMethod_FunctionDescriptor_values.containsKey(_parameters)) { 402 return (MethodDecl) targetStaticMethod_FunctionDescriptor_values.get(_parameters); 403 } 404 boolean intermediate = state.INTERMEDIATE_VALUE; 405 state.INTERMEDIATE_VALUE = false; 406 int num = state.boundariesCrossed; 407 boolean isFinal = this.is$Final(); 408 MethodDecl targetStaticMethod_FunctionDescriptor_value = targetStaticMethod_compute(f); 409 if (isFinal && num == state().boundariesCrossed) { 410 targetStaticMethod_FunctionDescriptor_values.put(_parameters, targetStaticMethod_FunctionDescriptor_value); 411 } else { 412 } 413 state.INTERMEDIATE_VALUE |= intermediate; 414 415 return targetStaticMethod_FunctionDescriptor_value; 416 } 417 /** 418 * @apilevel internal 419 */ 420 private MethodDecl targetStaticMethod_compute(FunctionDescriptor f) { 421 MethodAccess synAcc = syntheticStaticMethodAccess(f); 422 SimpleSet maxSpecific = synAcc.maxSpecific(synAcc.lookupMethod(synAcc.name())); 423 if (maxSpecific.size() == 1) { 424 return (MethodDecl) maxSpecific.iterator().next(); 425 } else { 426 return unknownMethod(); 427 } 428 } 429 /** 430 * @apilevel internal 431 */ 432 protected java.util.Map targetInstanceMethod_FunctionDescriptor_values; 433 /** 434 * @apilevel internal 435 */ 436 private void targetInstanceMethod_FunctionDescriptor_reset() { 437 targetInstanceMethod_FunctionDescriptor_values = null; 438 } 439 /** 440 * @attribute syn 441 * @aspect MethodReference 442 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:76 443 */ 444 @ASTNodeAnnotation.Attribute 445 public MethodDecl targetInstanceMethod(FunctionDescriptor f) { 446 Object _parameters = f; 447 if (targetInstanceMethod_FunctionDescriptor_values == null) targetInstanceMethod_FunctionDescriptor_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 448 ASTNode$State state = state(); 449 if (targetInstanceMethod_FunctionDescriptor_values.containsKey(_parameters)) { 450 return (MethodDecl) targetInstanceMethod_FunctionDescriptor_values.get(_parameters); 451 } 452 boolean intermediate = state.INTERMEDIATE_VALUE; 453 state.INTERMEDIATE_VALUE = false; 454 int num = state.boundariesCrossed; 455 boolean isFinal = this.is$Final(); 456 MethodDecl targetInstanceMethod_FunctionDescriptor_value = targetInstanceMethod_compute(f); 457 if (isFinal && num == state().boundariesCrossed) { 458 targetInstanceMethod_FunctionDescriptor_values.put(_parameters, targetInstanceMethod_FunctionDescriptor_value); 459 } else { 460 } 461 state.INTERMEDIATE_VALUE |= intermediate; 462 463 return targetInstanceMethod_FunctionDescriptor_value; 464 } 465 /** 466 * @apilevel internal 467 */ 468 private MethodDecl targetInstanceMethod_compute(FunctionDescriptor f) { 469 if (f.method.getNumParameter() == 0 470 || !f.method.getParameter(0).type().strictSubtype(getTypeAccess().type())) { 471 return unknownMethod(); 472 } 473 474 MethodAccess synAcc = syntheticInstanceMethodAccess(f); 475 SimpleSet maxSpecific = synAcc.maxSpecific(synAcc.lookupMethod(synAcc.name())); 476 if (maxSpecific.size() == 1) { 477 return (MethodDecl) maxSpecific.iterator().next(); 478 } else { 479 return unknownMethod(); 480 } 481 } 482 /** 483 * @apilevel internal 484 */ 485 protected java.util.Map validStaticMethod_FunctionDescriptor_values; 486 /** 487 * @apilevel internal 488 */ 489 private void validStaticMethod_FunctionDescriptor_reset() { 490 validStaticMethod_FunctionDescriptor_values = null; 491 } 492 /** 493 * @attribute syn 494 * @aspect MethodReference 495 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:91 496 */ 497 @ASTNodeAnnotation.Attribute 498 public boolean validStaticMethod(FunctionDescriptor f) { 499 Object _parameters = f; 500 if (validStaticMethod_FunctionDescriptor_values == null) validStaticMethod_FunctionDescriptor_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 501 ASTNode$State state = state(); 502 if (validStaticMethod_FunctionDescriptor_values.containsKey(_parameters)) { 503 return (Boolean) validStaticMethod_FunctionDescriptor_values.get(_parameters); 504 } 505 boolean intermediate = state.INTERMEDIATE_VALUE; 506 state.INTERMEDIATE_VALUE = false; 507 int num = state.boundariesCrossed; 508 boolean isFinal = this.is$Final(); 509 boolean validStaticMethod_FunctionDescriptor_value = validStaticMethod_compute(f); 510 if (isFinal && num == state().boundariesCrossed) { 511 validStaticMethod_FunctionDescriptor_values.put(_parameters, validStaticMethod_FunctionDescriptor_value); 512 } else { 513 } 514 state.INTERMEDIATE_VALUE |= intermediate; 515 516 return validStaticMethod_FunctionDescriptor_value; 517 } 518 /** 519 * @apilevel internal 520 */ 521 private boolean validStaticMethod_compute(FunctionDescriptor f) { 522 MethodDecl decl = targetStaticMethod(f); 523 return !(decl == unknownMethod() || !decl.isStatic()); 524 } 525 /** 526 * @apilevel internal 527 */ 528 protected java.util.Map validInstanceMethod_FunctionDescriptor_values; 529 /** 530 * @apilevel internal 531 */ 532 private void validInstanceMethod_FunctionDescriptor_reset() { 533 validInstanceMethod_FunctionDescriptor_values = null; 534 } 535 /** 536 * @attribute syn 537 * @aspect MethodReference 538 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:96 539 */ 540 @ASTNodeAnnotation.Attribute 541 public boolean validInstanceMethod(FunctionDescriptor f) { 542 Object _parameters = f; 543 if (validInstanceMethod_FunctionDescriptor_values == null) validInstanceMethod_FunctionDescriptor_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 544 ASTNode$State state = state(); 545 if (validInstanceMethod_FunctionDescriptor_values.containsKey(_parameters)) { 546 return (Boolean) validInstanceMethod_FunctionDescriptor_values.get(_parameters); 547 } 548 boolean intermediate = state.INTERMEDIATE_VALUE; 549 state.INTERMEDIATE_VALUE = false; 550 int num = state.boundariesCrossed; 551 boolean isFinal = this.is$Final(); 552 boolean validInstanceMethod_FunctionDescriptor_value = validInstanceMethod_compute(f); 553 if (isFinal && num == state().boundariesCrossed) { 554 validInstanceMethod_FunctionDescriptor_values.put(_parameters, validInstanceMethod_FunctionDescriptor_value); 555 } else { 556 } 557 state.INTERMEDIATE_VALUE |= intermediate; 558 559 return validInstanceMethod_FunctionDescriptor_value; 560 } 561 /** 562 * @apilevel internal 563 */ 564 private boolean validInstanceMethod_compute(FunctionDescriptor f) { 565 MethodDecl decl = targetInstanceMethod(f); 566 return !(decl == unknownMethod() || decl.isStatic()); 567 } 568 /** 569 * @apilevel internal 570 */ 571 protected java.util.Map inferredReferenceType_FunctionDescriptor_values; 572 /** 573 * @apilevel internal 574 */ 575 private void inferredReferenceType_FunctionDescriptor_reset() { 576 inferredReferenceType_FunctionDescriptor_values = null; 577 } 578 /** 579 * @attribute syn 580 * @aspect MethodReference 581 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:119 582 */ 583 @ASTNodeAnnotation.Attribute 584 public TypeDecl inferredReferenceType(FunctionDescriptor f) { 585 Object _parameters = f; 586 if (inferredReferenceType_FunctionDescriptor_values == null) inferredReferenceType_FunctionDescriptor_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 587 ASTNode$State state = state(); 588 if (inferredReferenceType_FunctionDescriptor_values.containsKey(_parameters)) { 589 return (TypeDecl) inferredReferenceType_FunctionDescriptor_values.get(_parameters); 590 } 591 boolean intermediate = state.INTERMEDIATE_VALUE; 592 state.INTERMEDIATE_VALUE = false; 593 int num = state.boundariesCrossed; 594 boolean isFinal = this.is$Final(); 595 TypeDecl inferredReferenceType_FunctionDescriptor_value = inferredReferenceType_compute(f); 596 if (isFinal && num == state().boundariesCrossed) { 597 inferredReferenceType_FunctionDescriptor_values.put(_parameters, inferredReferenceType_FunctionDescriptor_value); 598 } else { 599 } 600 state.INTERMEDIATE_VALUE |= intermediate; 601 602 return inferredReferenceType_FunctionDescriptor_value; 603 } 604 /** 605 * @apilevel internal 606 */ 607 private TypeDecl inferredReferenceType_compute(FunctionDescriptor f) { 608 if (f.method.getNumParameter() == 0) { 609 return null; 610 } else if (!(f.method.getParameter(0).getTypeAccess() instanceof ParTypeAccess)) { 611 return null; 612 } else if (!getTypeAccess().type().isRawType() || !(getTypeAccess() instanceof TypeAccess)) { 613 return null; 614 } 615 616 ParameterDeclaration param = f.method.getParameter(0); 617 if (!param.type().strictSubtype(param 618 .inferredReferenceAccess((TypeAccess) getTypeAccess()).type())) { 619 return null; 620 } 621 return param.inferredReferenceAccess((TypeAccess) getTypeAccess()).type(); 622 } 623 /** 624 * @apilevel internal 625 */ 626 protected List syntheticStaticAccess_FunctionDescriptor_list; 627 /** 628 * @apilevel internal 629 */ 630 protected java.util.Map syntheticStaticAccess_FunctionDescriptor_values; 631 /** 632 * @apilevel internal 633 */ 634 private void syntheticStaticAccess_FunctionDescriptor_reset() { 635 syntheticStaticAccess_FunctionDescriptor_values = null; 636 syntheticStaticAccess_FunctionDescriptor_list = null; 637 } 638 /** 639 * @attribute syn 640 * @aspect MethodReference 641 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:136 642 */ 643 @ASTNodeAnnotation.Attribute 644 public Access syntheticStaticAccess(FunctionDescriptor f) { 645 Object _parameters = f; 646 if (syntheticStaticAccess_FunctionDescriptor_values == null) syntheticStaticAccess_FunctionDescriptor_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 647 ASTNode$State state = state(); 648 if (syntheticStaticAccess_FunctionDescriptor_values.containsKey(_parameters)) { 649 return (Access) syntheticStaticAccess_FunctionDescriptor_values.get(_parameters); 650 } 651 boolean intermediate = state.INTERMEDIATE_VALUE; 652 state.INTERMEDIATE_VALUE = false; 653 int num = state.boundariesCrossed; 654 boolean isFinal = this.is$Final(); 655 Access syntheticStaticAccess_FunctionDescriptor_value = syntheticStaticAccess_compute(f); 656 if (syntheticStaticAccess_FunctionDescriptor_list == null) { 657 syntheticStaticAccess_FunctionDescriptor_list = new List(); 658 syntheticStaticAccess_FunctionDescriptor_list.is$Final = true; 659 syntheticStaticAccess_FunctionDescriptor_list.setParent(this); 660 } 661 syntheticStaticAccess_FunctionDescriptor_list.add(syntheticStaticAccess_FunctionDescriptor_value); 662 if (syntheticStaticAccess_FunctionDescriptor_value != null) { 663 syntheticStaticAccess_FunctionDescriptor_value = (Access) syntheticStaticAccess_FunctionDescriptor_list.getChild(syntheticStaticAccess_FunctionDescriptor_list.numChildren-1); 664 syntheticStaticAccess_FunctionDescriptor_value.is$Final = true; 665 } 666 if (true) { 667 syntheticStaticAccess_FunctionDescriptor_values.put(_parameters, syntheticStaticAccess_FunctionDescriptor_value); 668 } else { 669 } 670 state.INTERMEDIATE_VALUE |= intermediate; 671 672 return syntheticStaticAccess_FunctionDescriptor_value; 673 } 674 /** 675 * @apilevel internal 676 */ 677 private Access syntheticStaticAccess_compute(FunctionDescriptor f) { 678 List<Expr> arguments = new List<Expr>(); 679 for (int i = 0; i < f.method.getNumParameter(); i++) { 680 TypeDecl argumentType = f.method.getParameter(i).type(); 681 arguments.add(new SyntheticTypeAccess(argumentType)); 682 } 683 684 if (!hasTypeArgument()) { 685 MethodReferenceAccess mAccess = new MethodReferenceAccess(name(), arguments, f); 686 return ((Access) getTypeAccess().treeCopyNoTransform()).qualifiesAccess(mAccess); 687 } else { 688 ParMethodReferenceAccess pmAccess = new ParMethodReferenceAccess(name(), arguments, 689 (List<Access>) getTypeArgumentList().treeCopyNoTransform(), f); 690 return ((Access) getTypeAccess().treeCopyNoTransform()).qualifiesAccess(pmAccess); 691 } 692 } 693 /** 694 * @apilevel internal 695 */ 696 protected java.util.Map syntheticStaticMethodAccess_FunctionDescriptor_values; 697 /** 698 * @apilevel internal 699 */ 700 private void syntheticStaticMethodAccess_FunctionDescriptor_reset() { 701 syntheticStaticMethodAccess_FunctionDescriptor_values = null; 702 } 703 /** 704 * @attribute syn 705 * @aspect MethodReference 706 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:153 707 */ 708 @ASTNodeAnnotation.Attribute 709 public MethodAccess syntheticStaticMethodAccess(FunctionDescriptor f) { 710 Object _parameters = f; 711 if (syntheticStaticMethodAccess_FunctionDescriptor_values == null) syntheticStaticMethodAccess_FunctionDescriptor_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 712 ASTNode$State state = state(); 713 if (syntheticStaticMethodAccess_FunctionDescriptor_values.containsKey(_parameters)) { 714 return (MethodAccess) syntheticStaticMethodAccess_FunctionDescriptor_values.get(_parameters); 715 } 716 boolean intermediate = state.INTERMEDIATE_VALUE; 717 state.INTERMEDIATE_VALUE = false; 718 int num = state.boundariesCrossed; 719 boolean isFinal = this.is$Final(); 720 MethodAccess syntheticStaticMethodAccess_FunctionDescriptor_value = syntheticStaticMethodAccess_compute(f); 721 if (isFinal && num == state().boundariesCrossed) { 722 syntheticStaticMethodAccess_FunctionDescriptor_values.put(_parameters, syntheticStaticMethodAccess_FunctionDescriptor_value); 723 } else { 724 } 725 state.INTERMEDIATE_VALUE |= intermediate; 726 727 return syntheticStaticMethodAccess_FunctionDescriptor_value; 728 } 729 /** 730 * @apilevel internal 731 */ 732 private MethodAccess syntheticStaticMethodAccess_compute(FunctionDescriptor f) { 733 Access synAccess = syntheticStaticAccess(f); 734 return (MethodAccess) synAccess.lastAccess(); 735 } 736 /** 737 * @apilevel internal 738 */ 739 protected List syntheticInstanceAccess_FunctionDescriptor_list; 740 /** 741 * @apilevel internal 742 */ 743 protected java.util.Map syntheticInstanceAccess_FunctionDescriptor_values; 744 /** 745 * @apilevel internal 746 */ 747 private void syntheticInstanceAccess_FunctionDescriptor_reset() { 748 syntheticInstanceAccess_FunctionDescriptor_values = null; 749 syntheticInstanceAccess_FunctionDescriptor_list = null; 750 } 751 /** 752 * @attribute syn 753 * @aspect MethodReference 754 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:158 755 */ 756 @ASTNodeAnnotation.Attribute 757 public Access syntheticInstanceAccess(FunctionDescriptor f) { 758 Object _parameters = f; 759 if (syntheticInstanceAccess_FunctionDescriptor_values == null) syntheticInstanceAccess_FunctionDescriptor_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 760 ASTNode$State state = state(); 761 if (syntheticInstanceAccess_FunctionDescriptor_values.containsKey(_parameters)) { 762 return (Access) syntheticInstanceAccess_FunctionDescriptor_values.get(_parameters); 763 } 764 boolean intermediate = state.INTERMEDIATE_VALUE; 765 state.INTERMEDIATE_VALUE = false; 766 int num = state.boundariesCrossed; 767 boolean isFinal = this.is$Final(); 768 Access syntheticInstanceAccess_FunctionDescriptor_value = syntheticInstanceAccess_compute(f); 769 if (syntheticInstanceAccess_FunctionDescriptor_list == null) { 770 syntheticInstanceAccess_FunctionDescriptor_list = new List(); 771 syntheticInstanceAccess_FunctionDescriptor_list.is$Final = true; 772 syntheticInstanceAccess_FunctionDescriptor_list.setParent(this); 773 } 774 syntheticInstanceAccess_FunctionDescriptor_list.add(syntheticInstanceAccess_FunctionDescriptor_value); 775 if (syntheticInstanceAccess_FunctionDescriptor_value != null) { 776 syntheticInstanceAccess_FunctionDescriptor_value = (Access) syntheticInstanceAccess_FunctionDescriptor_list.getChild(syntheticInstanceAccess_FunctionDescriptor_list.numChildren-1); 777 syntheticInstanceAccess_FunctionDescriptor_value.is$Final = true; 778 } 779 if (true) { 780 syntheticInstanceAccess_FunctionDescriptor_values.put(_parameters, syntheticInstanceAccess_FunctionDescriptor_value); 781 } else { 782 } 783 state.INTERMEDIATE_VALUE |= intermediate; 784 785 return syntheticInstanceAccess_FunctionDescriptor_value; 786 } 787 /** 788 * @apilevel internal 789 */ 790 private Access syntheticInstanceAccess_compute(FunctionDescriptor f) { 791 List<Expr> arguments = new List<Expr>(); 792 for (int i = 1; i < f.method.getNumParameter(); i++) { 793 TypeDecl argumentType = f.method.getParameter(i).type(); 794 arguments.add(new SyntheticTypeAccess(argumentType)); 795 } 796 797 Access qualifier = null; 798 799 if (inferredReferenceType(f) != null) { 800 qualifier = new SyntheticTypeAccess(inferredReferenceType(f)); 801 } else { 802 qualifier = (Access) getTypeAccess().treeCopyNoTransform(); 803 } 804 805 if (!hasTypeArgument()) { 806 MethodReferenceAccess mAccess = new MethodReferenceAccess(name(), arguments, f); 807 return qualifier.qualifiesAccess(mAccess); 808 } else { 809 ParMethodReferenceAccess pmAccess = new ParMethodReferenceAccess(name(), arguments, 810 (List<Access>) getTypeArgumentList().treeCopyNoTransform(), f); 811 return qualifier.qualifiesAccess(pmAccess); 812 } 813 } 814 /** 815 * @apilevel internal 816 */ 817 protected java.util.Map syntheticInstanceMethodAccess_FunctionDescriptor_values; 818 /** 819 * @apilevel internal 820 */ 821 private void syntheticInstanceMethodAccess_FunctionDescriptor_reset() { 822 syntheticInstanceMethodAccess_FunctionDescriptor_values = null; 823 } 824 /** 825 * @attribute syn 826 * @aspect MethodReference 827 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:183 828 */ 829 @ASTNodeAnnotation.Attribute 830 public MethodAccess syntheticInstanceMethodAccess(FunctionDescriptor f) { 831 Object _parameters = f; 832 if (syntheticInstanceMethodAccess_FunctionDescriptor_values == null) syntheticInstanceMethodAccess_FunctionDescriptor_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 833 ASTNode$State state = state(); 834 if (syntheticInstanceMethodAccess_FunctionDescriptor_values.containsKey(_parameters)) { 835 return (MethodAccess) syntheticInstanceMethodAccess_FunctionDescriptor_values.get(_parameters); 836 } 837 boolean intermediate = state.INTERMEDIATE_VALUE; 838 state.INTERMEDIATE_VALUE = false; 839 int num = state.boundariesCrossed; 840 boolean isFinal = this.is$Final(); 841 MethodAccess syntheticInstanceMethodAccess_FunctionDescriptor_value = syntheticInstanceMethodAccess_compute(f); 842 if (isFinal && num == state().boundariesCrossed) { 843 syntheticInstanceMethodAccess_FunctionDescriptor_values.put(_parameters, syntheticInstanceMethodAccess_FunctionDescriptor_value); 844 } else { 845 } 846 state.INTERMEDIATE_VALUE |= intermediate; 847 848 return syntheticInstanceMethodAccess_FunctionDescriptor_value; 849 } 850 /** 851 * @apilevel internal 852 */ 853 private MethodAccess syntheticInstanceMethodAccess_compute(FunctionDescriptor f) { 854 Access synAccess = syntheticInstanceAccess(f); 855 return (MethodAccess) synAccess.lastAccess(); 856 } 857 /** 858 * @apilevel internal 859 */ 860 protected java.util.Map congruentTo_FunctionDescriptor_values; 861 /** 862 * @apilevel internal 863 */ 864 private void congruentTo_FunctionDescriptor_reset() { 865 congruentTo_FunctionDescriptor_values = null; 866 } 867 /** 868 * @attribute syn 869 * @aspect MethodReference 870 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:212 871 */ 872 @ASTNodeAnnotation.Attribute 873 public boolean congruentTo(FunctionDescriptor f) { 874 Object _parameters = f; 875 if (congruentTo_FunctionDescriptor_values == null) congruentTo_FunctionDescriptor_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 876 ASTNode$State state = state(); 877 if (congruentTo_FunctionDescriptor_values.containsKey(_parameters)) { 878 return (Boolean) congruentTo_FunctionDescriptor_values.get(_parameters); 879 } 880 boolean intermediate = state.INTERMEDIATE_VALUE; 881 state.INTERMEDIATE_VALUE = false; 882 int num = state.boundariesCrossed; 883 boolean isFinal = this.is$Final(); 884 boolean congruentTo_FunctionDescriptor_value = congruentTo_compute(f); 885 if (isFinal && num == state().boundariesCrossed) { 886 congruentTo_FunctionDescriptor_values.put(_parameters, congruentTo_FunctionDescriptor_value); 887 } else { 888 } 889 state.INTERMEDIATE_VALUE |= intermediate; 890 891 return congruentTo_FunctionDescriptor_value; 892 } 893 /** 894 * @apilevel internal 895 */ 896 private boolean congruentTo_compute(FunctionDescriptor f) { 897 MethodDecl staticMethod = targetStaticMethod(f); 898 MethodDecl instanceMethod = targetInstanceMethod(f); 899 if (unknownMethod() != staticMethod && unknownMethod() != instanceMethod) { 900 return false; 901 } else if (unknownMethod() == staticMethod && unknownMethod() == instanceMethod) { 902 return false; 903 } 904 MethodDecl found; 905 if (unknownMethod() != staticMethod) { 906 found = staticMethod; 907 } else { 908 found = instanceMethod; 909 } 910 if (f.method.type().isVoid()) { 911 return true; 912 } 913 if (found.type().isVoid()) { 914 return false; 915 } 916 return found.type().assignConversionTo(f.method.type(), null); 917 } 918 /** 919 * @apilevel internal 920 */ 921 protected java.util.Map potentiallyApplicableMethods_FunctionDescriptor_values; 922 /** 923 * @apilevel internal 924 */ 925 private void potentiallyApplicableMethods_FunctionDescriptor_reset() { 926 potentiallyApplicableMethods_FunctionDescriptor_values = null; 927 } 928 /** 929 * @attribute syn 930 * @aspect MethodReference 931 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:253 932 */ 933 @ASTNodeAnnotation.Attribute 934 public ArrayList<MethodDecl> potentiallyApplicableMethods(FunctionDescriptor f) { 935 Object _parameters = f; 936 if (potentiallyApplicableMethods_FunctionDescriptor_values == null) potentiallyApplicableMethods_FunctionDescriptor_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 937 ASTNode$State state = state(); 938 if (potentiallyApplicableMethods_FunctionDescriptor_values.containsKey(_parameters)) { 939 return (ArrayList<MethodDecl>) potentiallyApplicableMethods_FunctionDescriptor_values.get(_parameters); 940 } 941 boolean intermediate = state.INTERMEDIATE_VALUE; 942 state.INTERMEDIATE_VALUE = false; 943 int num = state.boundariesCrossed; 944 boolean isFinal = this.is$Final(); 945 ArrayList<MethodDecl> potentiallyApplicableMethods_FunctionDescriptor_value = potentiallyApplicableMethods_compute(f); 946 if (isFinal && num == state().boundariesCrossed) { 947 potentiallyApplicableMethods_FunctionDescriptor_values.put(_parameters, potentiallyApplicableMethods_FunctionDescriptor_value); 948 } else { 949 } 950 state.INTERMEDIATE_VALUE |= intermediate; 951 952 return potentiallyApplicableMethods_FunctionDescriptor_value; 953 } 954 /** 955 * @apilevel internal 956 */ 957 private ArrayList<MethodDecl> potentiallyApplicableMethods_compute(FunctionDescriptor f) { 958 Collection<MethodDecl> col = getTypeAccess().type().memberMethods(name()); 959 ArrayList<MethodDecl> applicable = new ArrayList<MethodDecl>(); 960 for (MethodDecl decl : col) { 961 if (!decl.accessibleFrom(hostType())) { 962 continue; 963 } 964 if (!(decl.arity() == f.method.arity()) && !(decl.arity() == f.method.arity() - 1)) { 965 continue; 966 } 967 if (hasTypeArgument()) { 968 if (!decl.isGeneric()) { 969 continue; 970 } 971 GenericMethodDecl genDecl = decl.genericDecl(); 972 if (!(getNumTypeArgument() == genDecl.getNumTypeParameter())) { 973 continue; 974 } 975 } 976 applicable.add(decl); 977 } 978 return applicable; 979 } 980 /** 981 * @apilevel internal 982 */ 983 protected boolean exactCompileTimeDeclaration_computed = false; 984 /** 985 * @apilevel internal 986 */ 987 protected MethodDecl exactCompileTimeDeclaration_value; 988 /** 989 * @apilevel internal 990 */ 991 private void exactCompileTimeDeclaration_reset() { 992 exactCompileTimeDeclaration_computed = false; 993 exactCompileTimeDeclaration_value = null; 994 } 995 /** 996 * @attribute syn 997 * @aspect MethodReference 998 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:308 999 */ 1000 @ASTNodeAnnotation.Attribute 1001 public MethodDecl exactCompileTimeDeclaration() { 1002 ASTNode$State state = state(); 1003 if (exactCompileTimeDeclaration_computed) { 1004 return exactCompileTimeDeclaration_value; 1005 } 1006 boolean intermediate = state.INTERMEDIATE_VALUE; 1007 state.INTERMEDIATE_VALUE = false; 1008 int num = state.boundariesCrossed; 1009 boolean isFinal = this.is$Final(); 1010 exactCompileTimeDeclaration_value = exactCompileTimeDeclaration_compute(); 1011 if (isFinal && num == state().boundariesCrossed) { 1012 exactCompileTimeDeclaration_computed = true; 1013 } else { 1014 } 1015 state.INTERMEDIATE_VALUE |= intermediate; 1016 1017 return exactCompileTimeDeclaration_value; 1018 } 1019 /** 1020 * @apilevel internal 1021 */ 1022 private MethodDecl exactCompileTimeDeclaration_compute() { 1023 if (getTypeAccess().type().isRawType()) { 1024 return unknownMethod(); 1025 } 1026 Collection<MethodDecl> col = getTypeAccess().type().memberMethods(name()); 1027 int foundCompatible = 0; 1028 MethodDecl latestDecl = null; 1029 for (MethodDecl decl : col) { 1030 if (decl.accessibleFrom(hostType())) { 1031 foundCompatible++; 1032 latestDecl = decl; 1033 } 1034 } 1035 if (foundCompatible != 1) { 1036 return unknownMethod(); 1037 } 1038 if (latestDecl.isVariableArity()) { 1039 return unknownMethod(); 1040 } 1041 if (latestDecl.isGeneric()) { 1042 GenericMethodDecl genericDecl = latestDecl.genericDecl(); 1043 if (getNumTypeArgument() == genericDecl.getNumTypeParameter()) { 1044 return latestDecl; 1045 } else { 1046 return unknownMethod(); 1047 } 1048 } 1049 return latestDecl; 1050 } 1051 /** 1052 * @apilevel internal 1053 */ 1054 protected java.util.Map potentiallyCompatible_TypeDecl_BodyDecl_values; 1055 /** 1056 * @apilevel internal 1057 */ 1058 private void potentiallyCompatible_TypeDecl_BodyDecl_reset() { 1059 potentiallyCompatible_TypeDecl_BodyDecl_values = null; 1060 } 1061 /** 1062 * @attribute syn 1063 * @aspect MethodSignature18 1064 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodSignature.jrag:466 1065 */ 1066 @ASTNodeAnnotation.Attribute 1067 public boolean potentiallyCompatible(TypeDecl type, BodyDecl candidateDecl) { 1068 java.util.List _parameters = new java.util.ArrayList(2); 1069 _parameters.add(type); 1070 _parameters.add(candidateDecl); 1071 if (potentiallyCompatible_TypeDecl_BodyDecl_values == null) potentiallyCompatible_TypeDecl_BodyDecl_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 1072 ASTNode$State state = state(); 1073 if (potentiallyCompatible_TypeDecl_BodyDecl_values.containsKey(_parameters)) { 1074 return (Boolean) potentiallyCompatible_TypeDecl_BodyDecl_values.get(_parameters); 1075 } 1076 boolean intermediate = state.INTERMEDIATE_VALUE; 1077 state.INTERMEDIATE_VALUE = false; 1078 int num = state.boundariesCrossed; 1079 boolean isFinal = this.is$Final(); 1080 boolean potentiallyCompatible_TypeDecl_BodyDecl_value = potentiallyCompatible_compute(type, candidateDecl); 1081 if (isFinal && num == state().boundariesCrossed) { 1082 potentiallyCompatible_TypeDecl_BodyDecl_values.put(_parameters, potentiallyCompatible_TypeDecl_BodyDecl_value); 1083 } else { 1084 } 1085 state.INTERMEDIATE_VALUE |= intermediate; 1086 1087 return potentiallyCompatible_TypeDecl_BodyDecl_value; 1088 } 1089 /** 1090 * @apilevel internal 1091 */ 1092 private boolean potentiallyCompatible_compute(TypeDecl type, BodyDecl candidateDecl) { 1093 if (super.potentiallyCompatible(type, candidateDecl) && type.isTypeVariable()) { 1094 return true; 1095 } else if (!super.potentiallyCompatible(type, candidateDecl)) { 1096 return false; 1097 } 1098 1099 InterfaceDecl iDecl = (InterfaceDecl) type; 1100 FunctionDescriptor f = iDecl.functionDescriptor(); 1101 1102 boolean foundMethod = false; 1103 for (MethodDecl decl : potentiallyApplicableMethods(f)) { 1104 if (decl.isStatic() && f.method.arity() == decl.arity()) { 1105 foundMethod = true; 1106 break; 1107 } else if (!decl.isStatic() && f.method.arity() - 1 == decl.arity()) { 1108 foundMethod = true; 1109 break; 1110 } 1111 } 1112 return foundMethod; 1113 } 1114 /** 1115 * @apilevel internal 1116 */ 1117 protected boolean toClass_computed = false; 1118 /** 1119 * @apilevel internal 1120 */ 1121 protected ClassInstanceExpr toClass_value; 1122 /** 1123 * @apilevel internal 1124 */ 1125 private void toClass_reset() { 1126 toClass_computed = false; 1127 toClass_value = null; 1128 } 1129 /** 1130 * @attribute syn 1131 * @aspect MethodReferenceToClass 1132 * @declaredat /home/jesper/git/extendj/java8/backend/MethodReferenceToClass.jrag:129 1133 */ 1134 @ASTNodeAnnotation.Attribute 1135 public ClassInstanceExpr toClass() { 1136 ASTNode$State state = state(); 1137 if (toClass_computed) { 1138 return toClass_value; 1139 } 1140 boolean intermediate = state.INTERMEDIATE_VALUE; 1141 state.INTERMEDIATE_VALUE = false; 1142 int num = state.boundariesCrossed; 1143 boolean isFinal = this.is$Final(); 1144 toClass_value = toClass_compute(); 1145 toClass_value.setParent(this); 1146 toClass_value.is$Final = true; 1147 if (true) { 1148 toClass_computed = true; 1149 } else { 1150 } 1151 state.INTERMEDIATE_VALUE |= intermediate; 1152 1153 return toClass_value; 1154 } 1155 /** 1156 * @apilevel internal 1157 */ 1158 private ClassInstanceExpr toClass_compute() { 1159 List<Access> implementsList = new List<Access>(); 1160 InterfaceDecl iDecl = targetInterface(); 1161 1162 // First compute the interface implemented by the anonymous class 1163 Access implementsInterface = iDecl.createQualifiedAccess(); 1164 implementsList.add(implementsInterface); 1165 1166 // Next compute the BodyDecl for the anonymous class 1167 List<BodyDecl> bodyDecls = new List<BodyDecl>(); 1168 1169 // For TypeMethodReferenes, there is only one body decl, the method 1170 1171 Modifiers methodModifiers = new Modifiers(new List<Modifier>().add(new Modifier("public"))); 1172 Access returnType = new SyntheticTypeAccess(iDecl.functionDescriptor().method.type()); 1173 List<ParameterDeclaration> methodParams = toParameterList(); 1174 List<Access> methodThrows = new List<Access>(); 1175 for (TypeDecl throwsType : iDecl.functionDescriptor().throwsList) { 1176 methodThrows.add(new SyntheticTypeAccess(throwsType)); 1177 } 1178 Opt<Block> methodBlock = new Opt<Block>(toBlock()); 1179 MethodDecl method = new MethodDecl(methodModifiers, returnType, iDecl.functionDescriptor().method.name(), 1180 methodParams, methodThrows, methodBlock); 1181 1182 bodyDecls.add(method); 1183 1184 /* Now the anonymous class can be built. Must use the type LambdaAnonymousDecl instead 1185 of a normal AnonymousDecl in order for this and super keywords to get the type of the outer 1186 scope. */ 1187 LambdaAnonymousDecl anonymousDecl = new LambdaAnonymousDecl(new Modifiers(), "MethodReference", bodyDecls); 1188 for (Access impl: implementsList) { 1189 anonymousDecl.addImplements(impl); 1190 } 1191 1192 return new ClassInstanceExpr((Access) implementsInterface.treeCopyNoTransform(), new List<Expr>(), new Opt<TypeDecl>(anonymousDecl)); 1193 } 1194 /** 1195 * @apilevel internal 1196 */ 1197 protected boolean toBlock_computed = false; 1198 /** 1199 * @apilevel internal 1200 */ 1201 protected Block toBlock_value; 1202 /** 1203 * @apilevel internal 1204 */ 1205 private void toBlock_reset() { 1206 toBlock_computed = false; 1207 toBlock_value = null; 1208 } 1209 /** 1210 * @attribute syn 1211 * @aspect MethodReferenceToClass 1212 * @declaredat /home/jesper/git/extendj/java8/backend/MethodReferenceToClass.jrag:166 1213 */ 1214 @ASTNodeAnnotation.Attribute 1215 public Block toBlock() { 1216 ASTNode$State state = state(); 1217 if (toBlock_computed) { 1218 return toBlock_value; 1219 } 1220 boolean intermediate = state.INTERMEDIATE_VALUE; 1221 state.INTERMEDIATE_VALUE = false; 1222 int num = state.boundariesCrossed; 1223 boolean isFinal = this.is$Final(); 1224 toBlock_value = toBlock_compute(); 1225 if (isFinal && num == state().boundariesCrossed) { 1226 toBlock_computed = true; 1227 } else { 1228 } 1229 state.INTERMEDIATE_VALUE |= intermediate; 1230 1231 return toBlock_value; 1232 } 1233 /** 1234 * @apilevel internal 1235 */ 1236 private Block toBlock_compute() { 1237 Expr qualifier = null; 1238 List<Expr> arguments = new List<Expr>(); 1239 FunctionDescriptor f = targetInterface().functionDescriptor(); 1240 // Should create access to instance method 1241 if (!validStaticMethod(f)) { 1242 qualifier = new VarAccess(targetInterface().functionDescriptor().method.getParameter(0).name()); 1243 for (int i = 1; i < targetInterface().functionDescriptor().method.getNumParameter(); i++) { 1244 String paramName = targetInterface().functionDescriptor().method.getParameter(i).name(); 1245 arguments.add(new VarAccess(paramName)); 1246 } 1247 } 1248 // Should create access to static method 1249 else { 1250 qualifier = (Access) getTypeAccess().treeCopyNoTransform(); 1251 for (int i = 0; i < targetInterface().functionDescriptor().method.getNumParameter(); i++) { 1252 String paramName = targetInterface().functionDescriptor().method.getParameter(i).name(); 1253 arguments.add(new VarAccess(paramName)); 1254 } 1255 } 1256 1257 MethodAccess m = null; 1258 if (!hasTypeArgument()) { 1259 m = new MethodAccess(name(), arguments); 1260 } else { 1261 m = new ParMethodAccess(name(), arguments, (List<Access>)getTypeArgumentList().treeCopyNoTransform()); 1262 } 1263 Access qualifiedMethod = qualifier.qualifiesAccess(m); 1264 Stmt blockStmt = null; 1265 if (targetInterface().functionDescriptor().method.type().isVoid()) { 1266 blockStmt = new ExprStmt(qualifiedMethod); 1267 } else { 1268 blockStmt = new ReturnStmt(qualifiedMethod); 1269 } 1270 List<Stmt> stmtList = new List<Stmt>(); 1271 stmtList.add(blockStmt); 1272 return new Block(stmtList); 1273 } 1274 /** 1275 * @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:36 1276 * @apilevel internal 1277 */ 1278 public NameType Define_nameType(ASTNode caller, ASTNode child) { 1279 if (caller == getTypeAccessNoTransform()) { 1280 // @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:195 1281 return NameType.TYPE_NAME; 1282 } 1283 else { 1284 return super.Define_nameType(caller, child); 1285 } 1286 } 1287 protected boolean canDefine_nameType(ASTNode caller, ASTNode child) { 1288 return true; 1289 } 1290 /** 1291 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:196 1292 * @apilevel internal 1293 */ 1294 public boolean Define_assignmentContext(ASTNode caller, ASTNode child) { 1295 if (caller == getTypeAccessNoTransform()) { 1296 // @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:391 1297 return false; 1298 } 1299 else { 1300 return getParent().Define_assignmentContext(this, caller); 1301 } 1302 } 1303 protected boolean canDefine_assignmentContext(ASTNode caller, ASTNode child) { 1304 return true; 1305 } 1306 /** 1307 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:197 1308 * @apilevel internal 1309 */ 1310 public boolean Define_invocationContext(ASTNode caller, ASTNode child) { 1311 if (caller == getTypeAccessNoTransform()) { 1312 // @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:392 1313 return false; 1314 } 1315 else { 1316 return getParent().Define_invocationContext(this, caller); 1317 } 1318 } 1319 protected boolean canDefine_invocationContext(ASTNode caller, ASTNode child) { 1320 return true; 1321 } 1322 /** 1323 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:198 1324 * @apilevel internal 1325 */ 1326 public boolean Define_castContext(ASTNode caller, ASTNode child) { 1327 if (caller == getTypeAccessNoTransform()) { 1328 // @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:393 1329 return false; 1330 } 1331 else { 1332 return getParent().Define_castContext(this, caller); 1333 } 1334 } 1335 protected boolean canDefine_castContext(ASTNode caller, ASTNode child) { 1336 return true; 1337 } 1338 /** 1339 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:199 1340 * @apilevel internal 1341 */ 1342 public boolean Define_stringContext(ASTNode caller, ASTNode child) { 1343 if (caller == getTypeAccessNoTransform()) { 1344 // @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:394 1345 return false; 1346 } 1347 else { 1348 return getParent().Define_stringContext(this, caller); 1349 } 1350 } 1351 protected boolean canDefine_stringContext(ASTNode caller, ASTNode child) { 1352 return true; 1353 } 1354 /** 1355 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:200 1356 * @apilevel internal 1357 */ 1358 public boolean Define_numericContext(ASTNode caller, ASTNode child) { 1359 if (caller == getTypeAccessNoTransform()) { 1360 // @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:395 1361 return false; 1362 } 1363 else { 1364 return getParent().Define_numericContext(this, caller); 1365 } 1366 } 1367 protected boolean canDefine_numericContext(ASTNode caller, ASTNode child) { 1368 return true; 1369 } 1370 /** 1371 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericMethodsInference.jrag:58 1372 * @apilevel internal 1373 */ 1374 public TypeDecl Define_assignConvertedType(ASTNode caller, ASTNode child) { 1375 if (caller == toClass_value) { 1376 // @declaredat /home/jesper/git/extendj/java8/backend/ToClassInherited.jrag:40 1377 { 1378 return targetInterface().functionDescriptor().method.type(); 1379 } 1380 } 1381 else { 1382 return getParent().Define_assignConvertedType(this, caller); 1383 } 1384 } 1385 protected boolean canDefine_assignConvertedType(ASTNode caller, ASTNode child) { 1386 return true; 1387 } 1388 /** 1389 * @apilevel internal 1390 */ 1391 public ASTNode rewriteTo() { 1392 return super.rewriteTo(); 1393 } 1394 }