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