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:5 027 * @production AmbiguousMethodReference : {@link MethodReference} ::= <span class="component">AmbiguousName:{@link Access}</span>; 028 029 */ 030 public class AmbiguousMethodReference extends MethodReference implements Cloneable { 031 /** 032 * @declaredat ASTNode:1 033 */ 034 public AmbiguousMethodReference() { 035 super(); 036 } 037 /** 038 * Initializes the child array to the correct size. 039 * Initializes List and Opt nta children. 040 * @apilevel internal 041 * @ast method 042 * @declaredat ASTNode:10 043 */ 044 public void init$Children() { 045 children = new ASTNode[2]; 046 setChild(new List(), 0); 047 } 048 /** 049 * @declaredat ASTNode:14 050 */ 051 public AmbiguousMethodReference(List<Access> p0, String p1, Access p2) { 052 setChild(p0, 0); 053 setID(p1); 054 setChild(p2, 1); 055 } 056 /** 057 * @declaredat ASTNode:19 058 */ 059 public AmbiguousMethodReference(List<Access> p0, beaver.Symbol p1, Access p2) { 060 setChild(p0, 0); 061 setID(p1); 062 setChild(p2, 1); 063 } 064 /** 065 * @apilevel low-level 066 * @declaredat ASTNode:27 067 */ 068 protected int numChildren() { 069 return 2; 070 } 071 /** 072 * @apilevel internal 073 * @declaredat ASTNode:33 074 */ 075 public boolean mayHaveRewrite() { 076 return true; 077 } 078 /** 079 * @apilevel internal 080 * @declaredat ASTNode:39 081 */ 082 public void flushAttrCache() { 083 super.flushAttrCache(); 084 congruentTo_FunctionDescriptor_reset(); 085 potentiallyApplicableMethods_FunctionDescriptor_reset(); 086 exactCompileTimeDeclaration_reset(); 087 } 088 /** 089 * @apilevel internal 090 * @declaredat ASTNode:48 091 */ 092 public void flushCollectionCache() { 093 super.flushCollectionCache(); 094 } 095 /** 096 * @apilevel internal 097 * @declaredat ASTNode:54 098 */ 099 public void flushRewriteCache() { 100 super.flushRewriteCache(); 101 } 102 /** 103 * @apilevel internal 104 * @declaredat ASTNode:60 105 */ 106 public AmbiguousMethodReference clone() throws CloneNotSupportedException { 107 AmbiguousMethodReference node = (AmbiguousMethodReference) super.clone(); 108 return node; 109 } 110 /** 111 * @apilevel internal 112 * @declaredat ASTNode:67 113 */ 114 public AmbiguousMethodReference copy() { 115 try { 116 AmbiguousMethodReference node = (AmbiguousMethodReference) clone(); 117 node.parent = null; 118 if (children != null) { 119 node.children = (ASTNode[]) children.clone(); 120 } 121 return node; 122 } catch (CloneNotSupportedException e) { 123 throw new Error("Error: clone not supported for " + getClass().getName()); 124 } 125 } 126 /** 127 * Create a deep copy of the AST subtree at this node. 128 * The copy is dangling, i.e. has no parent. 129 * @return dangling copy of the subtree at this node 130 * @apilevel low-level 131 * @deprecated Please use treeCopy or treeCopyNoTransform instead 132 * @declaredat ASTNode:86 133 */ 134 @Deprecated 135 public AmbiguousMethodReference fullCopy() { 136 return treeCopyNoTransform(); 137 } 138 /** 139 * Create a deep copy of the AST subtree at this node. 140 * The copy is dangling, i.e. has no parent. 141 * @return dangling copy of the subtree at this node 142 * @apilevel low-level 143 * @declaredat ASTNode:96 144 */ 145 public AmbiguousMethodReference treeCopyNoTransform() { 146 AmbiguousMethodReference tree = (AmbiguousMethodReference) copy(); 147 if (children != null) { 148 for (int i = 0; i < children.length; ++i) { 149 ASTNode child = (ASTNode) children[i]; 150 if (child != null) { 151 child = child.treeCopyNoTransform(); 152 tree.setChild(child, i); 153 } 154 } 155 } 156 return tree; 157 } 158 /** 159 * Create a deep copy of the AST subtree at this node. 160 * The subtree of this node is traversed to trigger rewrites before copy. 161 * The copy is dangling, i.e. has no parent. 162 * @return dangling copy of the subtree at this node 163 * @apilevel low-level 164 * @declaredat ASTNode:116 165 */ 166 public AmbiguousMethodReference treeCopy() { 167 doFullTraversal(); 168 return treeCopyNoTransform(); 169 } 170 /** 171 * @apilevel internal 172 * @declaredat ASTNode:123 173 */ 174 protected boolean is$Equal(ASTNode node) { 175 return super.is$Equal(node) && (tokenString_ID == ((AmbiguousMethodReference)node).tokenString_ID); 176 } 177 /** 178 * Replaces the TypeArgument list. 179 * @param list The new list node to be used as the TypeArgument list. 180 * @apilevel high-level 181 */ 182 public void setTypeArgumentList(List<Access> list) { 183 setChild(list, 0); 184 } 185 /** 186 * Retrieves the number of children in the TypeArgument list. 187 * @return Number of children in the TypeArgument list. 188 * @apilevel high-level 189 */ 190 public int getNumTypeArgument() { 191 return getTypeArgumentList().getNumChild(); 192 } 193 /** 194 * Retrieves the number of children in the TypeArgument list. 195 * Calling this method will not trigger rewrites. 196 * @return Number of children in the TypeArgument list. 197 * @apilevel low-level 198 */ 199 public int getNumTypeArgumentNoTransform() { 200 return getTypeArgumentListNoTransform().getNumChildNoTransform(); 201 } 202 /** 203 * Retrieves the element at index {@code i} in the TypeArgument list. 204 * @param i Index of the element to return. 205 * @return The element at position {@code i} in the TypeArgument list. 206 * @apilevel high-level 207 */ 208 public Access getTypeArgument(int i) { 209 return (Access) getTypeArgumentList().getChild(i); 210 } 211 /** 212 * Check whether the TypeArgument list has any children. 213 * @return {@code true} if it has at least one child, {@code false} otherwise. 214 * @apilevel high-level 215 */ 216 public boolean hasTypeArgument() { 217 return getTypeArgumentList().getNumChild() != 0; 218 } 219 /** 220 * Append an element to the TypeArgument list. 221 * @param node The element to append to the TypeArgument list. 222 * @apilevel high-level 223 */ 224 public void addTypeArgument(Access node) { 225 List<Access> list = (parent == null) ? getTypeArgumentListNoTransform() : getTypeArgumentList(); 226 list.addChild(node); 227 } 228 /** 229 * @apilevel low-level 230 */ 231 public void addTypeArgumentNoTransform(Access node) { 232 List<Access> list = getTypeArgumentListNoTransform(); 233 list.addChild(node); 234 } 235 /** 236 * Replaces the TypeArgument list element at index {@code i} with the new node {@code node}. 237 * @param node The new node to replace the old list element. 238 * @param i The list index of the node to be replaced. 239 * @apilevel high-level 240 */ 241 public void setTypeArgument(Access node, int i) { 242 List<Access> list = getTypeArgumentList(); 243 list.setChild(node, i); 244 } 245 /** 246 * Retrieves the TypeArgument list. 247 * @return The node representing the TypeArgument list. 248 * @apilevel high-level 249 */ 250 @ASTNodeAnnotation.ListChild(name="TypeArgument") 251 public List<Access> getTypeArgumentList() { 252 List<Access> list = (List<Access>) getChild(0); 253 return list; 254 } 255 /** 256 * Retrieves the TypeArgument list. 257 * <p><em>This method does not invoke AST transformations.</em></p> 258 * @return The node representing the TypeArgument list. 259 * @apilevel low-level 260 */ 261 public List<Access> getTypeArgumentListNoTransform() { 262 return (List<Access>) getChildNoTransform(0); 263 } 264 /** 265 * Retrieves the TypeArgument list. 266 * @return The node representing the TypeArgument list. 267 * @apilevel high-level 268 */ 269 public List<Access> getTypeArguments() { 270 return getTypeArgumentList(); 271 } 272 /** 273 * Retrieves the TypeArgument list. 274 * <p><em>This method does not invoke AST transformations.</em></p> 275 * @return The node representing the TypeArgument list. 276 * @apilevel low-level 277 */ 278 public List<Access> getTypeArgumentsNoTransform() { 279 return getTypeArgumentListNoTransform(); 280 } 281 /** 282 * Replaces the lexeme ID. 283 * @param value The new value for the lexeme ID. 284 * @apilevel high-level 285 */ 286 public void setID(String value) { 287 tokenString_ID = value; 288 } 289 /** 290 * JastAdd-internal setter for lexeme ID using the Beaver parser. 291 * @param symbol Symbol containing the new value for the lexeme ID 292 * @apilevel internal 293 */ 294 public void setID(beaver.Symbol symbol) { 295 if (symbol.value != null && !(symbol.value instanceof String)) 296 throw new UnsupportedOperationException("setID is only valid for String lexemes"); 297 tokenString_ID = (String)symbol.value; 298 IDstart = symbol.getStart(); 299 IDend = symbol.getEnd(); 300 } 301 /** 302 * Retrieves the value for the lexeme ID. 303 * @return The value for the lexeme ID. 304 * @apilevel high-level 305 */ 306 @ASTNodeAnnotation.Token(name="ID") 307 public String getID() { 308 return tokenString_ID != null ? tokenString_ID : ""; 309 } 310 /** 311 * Replaces the AmbiguousName child. 312 * @param node The new node to replace the AmbiguousName child. 313 * @apilevel high-level 314 */ 315 public void setAmbiguousName(Access node) { 316 setChild(node, 1); 317 } 318 /** 319 * Retrieves the AmbiguousName child. 320 * @return The current node used as the AmbiguousName child. 321 * @apilevel high-level 322 */ 323 @ASTNodeAnnotation.Child(name="AmbiguousName") 324 public Access getAmbiguousName() { 325 return (Access) getChild(1); 326 } 327 /** 328 * Retrieves the AmbiguousName child. 329 * <p><em>This method does not invoke AST transformations.</em></p> 330 * @return The current node used as the AmbiguousName child. 331 * @apilevel low-level 332 */ 333 public Access getAmbiguousNameNoTransform() { 334 return (Access) getChildNoTransform(1); 335 } 336 /** 337 * @apilevel internal 338 */ 339 protected java.util.Map congruentTo_FunctionDescriptor_values; 340 /** 341 * @apilevel internal 342 */ 343 private void congruentTo_FunctionDescriptor_reset() { 344 congruentTo_FunctionDescriptor_values = null; 345 } 346 /** 347 * @attribute syn 348 * @aspect MethodReference 349 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:212 350 */ 351 @ASTNodeAnnotation.Attribute 352 public boolean congruentTo(FunctionDescriptor f) { 353 Object _parameters = f; 354 if (congruentTo_FunctionDescriptor_values == null) congruentTo_FunctionDescriptor_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 355 ASTNode$State state = state(); 356 if (congruentTo_FunctionDescriptor_values.containsKey(_parameters)) { 357 return (Boolean) congruentTo_FunctionDescriptor_values.get(_parameters); 358 } 359 boolean intermediate = state.INTERMEDIATE_VALUE; 360 state.INTERMEDIATE_VALUE = false; 361 int num = state.boundariesCrossed; 362 boolean isFinal = this.is$Final(); 363 boolean congruentTo_FunctionDescriptor_value = false; 364 if (isFinal && num == state().boundariesCrossed) { 365 congruentTo_FunctionDescriptor_values.put(_parameters, congruentTo_FunctionDescriptor_value); 366 } else { 367 } 368 state.INTERMEDIATE_VALUE |= intermediate; 369 370 return congruentTo_FunctionDescriptor_value; 371 } 372 /** 373 * @apilevel internal 374 */ 375 protected java.util.Map potentiallyApplicableMethods_FunctionDescriptor_values; 376 /** 377 * @apilevel internal 378 */ 379 private void potentiallyApplicableMethods_FunctionDescriptor_reset() { 380 potentiallyApplicableMethods_FunctionDescriptor_values = null; 381 } 382 /** 383 * @attribute syn 384 * @aspect MethodReference 385 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:253 386 */ 387 @ASTNodeAnnotation.Attribute 388 public ArrayList<MethodDecl> potentiallyApplicableMethods(FunctionDescriptor f) { 389 Object _parameters = f; 390 if (potentiallyApplicableMethods_FunctionDescriptor_values == null) potentiallyApplicableMethods_FunctionDescriptor_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 391 ASTNode$State state = state(); 392 if (potentiallyApplicableMethods_FunctionDescriptor_values.containsKey(_parameters)) { 393 return (ArrayList<MethodDecl>) potentiallyApplicableMethods_FunctionDescriptor_values.get(_parameters); 394 } 395 boolean intermediate = state.INTERMEDIATE_VALUE; 396 state.INTERMEDIATE_VALUE = false; 397 int num = state.boundariesCrossed; 398 boolean isFinal = this.is$Final(); 399 ArrayList<MethodDecl> potentiallyApplicableMethods_FunctionDescriptor_value = new ArrayList<MethodDecl>(); 400 if (isFinal && num == state().boundariesCrossed) { 401 potentiallyApplicableMethods_FunctionDescriptor_values.put(_parameters, potentiallyApplicableMethods_FunctionDescriptor_value); 402 } else { 403 } 404 state.INTERMEDIATE_VALUE |= intermediate; 405 406 return potentiallyApplicableMethods_FunctionDescriptor_value; 407 } 408 /** 409 * @apilevel internal 410 */ 411 protected boolean exactCompileTimeDeclaration_computed = false; 412 /** 413 * @apilevel internal 414 */ 415 protected MethodDecl exactCompileTimeDeclaration_value; 416 /** 417 * @apilevel internal 418 */ 419 private void exactCompileTimeDeclaration_reset() { 420 exactCompileTimeDeclaration_computed = false; 421 exactCompileTimeDeclaration_value = null; 422 } 423 /** 424 * @attribute syn 425 * @aspect MethodReference 426 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:308 427 */ 428 @ASTNodeAnnotation.Attribute 429 public MethodDecl exactCompileTimeDeclaration() { 430 ASTNode$State state = state(); 431 if (exactCompileTimeDeclaration_computed) { 432 return exactCompileTimeDeclaration_value; 433 } 434 boolean intermediate = state.INTERMEDIATE_VALUE; 435 state.INTERMEDIATE_VALUE = false; 436 int num = state.boundariesCrossed; 437 boolean isFinal = this.is$Final(); 438 exactCompileTimeDeclaration_value = unknownMethod(); 439 if (isFinal && num == state().boundariesCrossed) { 440 exactCompileTimeDeclaration_computed = true; 441 } else { 442 } 443 state.INTERMEDIATE_VALUE |= intermediate; 444 445 return exactCompileTimeDeclaration_value; 446 } 447 /** 448 * @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:36 449 * @apilevel internal 450 */ 451 public NameType Define_nameType(ASTNode caller, ASTNode child) { 452 if (caller == getAmbiguousNameNoTransform()) { 453 // @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:196 454 return NameType.AMBIGUOUS_NAME; 455 } 456 else { 457 return super.Define_nameType(caller, child); 458 } 459 } 460 protected boolean canDefine_nameType(ASTNode caller, ASTNode child) { 461 return true; 462 } 463 /** 464 * @apilevel internal 465 */ 466 public ASTNode rewriteTo() { 467 // Declared at /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:199 468 if (!getAmbiguousName().isTypeAccess()) { 469 return rewriteRule0(); 470 } 471 // Declared at /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:206 472 if (getAmbiguousName().isTypeAccess()) { 473 return rewriteRule1(); 474 } 475 return super.rewriteTo(); 476 } 477 /** 478 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:199 479 * @apilevel internal 480 */ 481 private ExprMethodReference rewriteRule0() { 482 { 483 return new ExprMethodReference(getTypeArgumentList(), getID(), getAmbiguousName()); 484 } } 485 /** 486 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:206 487 * @apilevel internal 488 */ 489 private TypeMethodReference rewriteRule1() { 490 { 491 return new TypeMethodReference(getTypeArgumentList(), getID(), getAmbiguousName()); 492 } } 493 }