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:7 027 * @production MethodReferenceAccess : {@link MethodAccess}; 028 029 */ 030 public class MethodReferenceAccess extends MethodAccess implements Cloneable { 031 /** 032 * @aspect Synthetics 033 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:379 034 */ 035 private FunctionDescriptor targetDescriptor; 036 /** 037 * @aspect Synthetics 038 * @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:380 039 */ 040 public MethodReferenceAccess(String name, 041 List<Expr> args, FunctionDescriptor f) { 042 super(name, args); 043 this.targetDescriptor = f; 044 } 045 /** 046 * @declaredat ASTNode:1 047 */ 048 public MethodReferenceAccess() { 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[1]; 060 setChild(new List(), 0); 061 } 062 /** 063 * @declaredat ASTNode:14 064 */ 065 public MethodReferenceAccess(String p0, List<Expr> p1) { 066 setID(p0); 067 setChild(p1, 0); 068 } 069 /** 070 * @declaredat ASTNode:18 071 */ 072 public MethodReferenceAccess(beaver.Symbol p0, List<Expr> p1) { 073 setID(p0); 074 setChild(p1, 0); 075 } 076 /** 077 * @apilevel low-level 078 * @declaredat ASTNode:25 079 */ 080 protected int numChildren() { 081 return 1; 082 } 083 /** 084 * @apilevel internal 085 * @declaredat ASTNode:31 086 */ 087 public boolean mayHaveRewrite() { 088 return false; 089 } 090 /** 091 * @apilevel internal 092 * @declaredat ASTNode:37 093 */ 094 public void flushAttrCache() { 095 super.flushAttrCache(); 096 assignConvertedType_reset(); 097 } 098 /** 099 * @apilevel internal 100 * @declaredat ASTNode:44 101 */ 102 public void flushCollectionCache() { 103 super.flushCollectionCache(); 104 } 105 /** 106 * @apilevel internal 107 * @declaredat ASTNode:50 108 */ 109 public void flushRewriteCache() { 110 super.flushRewriteCache(); 111 } 112 /** 113 * @apilevel internal 114 * @declaredat ASTNode:56 115 */ 116 public MethodReferenceAccess clone() throws CloneNotSupportedException { 117 MethodReferenceAccess node = (MethodReferenceAccess) super.clone(); 118 return node; 119 } 120 /** 121 * @apilevel internal 122 * @declaredat ASTNode:63 123 */ 124 public MethodReferenceAccess copy() { 125 try { 126 MethodReferenceAccess node = (MethodReferenceAccess) clone(); 127 node.parent = null; 128 if (children != null) { 129 node.children = (ASTNode[]) children.clone(); 130 } 131 return node; 132 } catch (CloneNotSupportedException e) { 133 throw new Error("Error: clone not supported for " + getClass().getName()); 134 } 135 } 136 /** 137 * Create a deep copy of the AST subtree at this node. 138 * The copy is dangling, i.e. has no parent. 139 * @return dangling copy of the subtree at this node 140 * @apilevel low-level 141 * @deprecated Please use treeCopy or treeCopyNoTransform instead 142 * @declaredat ASTNode:82 143 */ 144 @Deprecated 145 public MethodReferenceAccess fullCopy() { 146 return treeCopyNoTransform(); 147 } 148 /** 149 * Create a deep copy of the AST subtree at this node. 150 * The copy is dangling, i.e. has no parent. 151 * @return dangling copy of the subtree at this node 152 * @apilevel low-level 153 * @declaredat ASTNode:92 154 */ 155 public MethodReferenceAccess treeCopyNoTransform() { 156 MethodReferenceAccess tree = (MethodReferenceAccess) copy(); 157 if (children != null) { 158 for (int i = 0; i < children.length; ++i) { 159 ASTNode child = (ASTNode) children[i]; 160 if (child != null) { 161 child = child.treeCopyNoTransform(); 162 tree.setChild(child, i); 163 } 164 } 165 } 166 return tree; 167 } 168 /** 169 * Create a deep copy of the AST subtree at this node. 170 * The subtree of this node is traversed to trigger rewrites before copy. 171 * The copy is dangling, i.e. has no parent. 172 * @return dangling copy of the subtree at this node 173 * @apilevel low-level 174 * @declaredat ASTNode:112 175 */ 176 public MethodReferenceAccess treeCopy() { 177 doFullTraversal(); 178 return treeCopyNoTransform(); 179 } 180 /** 181 * @apilevel internal 182 * @declaredat ASTNode:119 183 */ 184 protected boolean is$Equal(ASTNode node) { 185 return super.is$Equal(node) && (tokenString_ID == ((MethodReferenceAccess)node).tokenString_ID); 186 } 187 /** 188 * Replaces the lexeme ID. 189 * @param value The new value for the lexeme ID. 190 * @apilevel high-level 191 */ 192 public void setID(String value) { 193 tokenString_ID = value; 194 } 195 /** 196 * JastAdd-internal setter for lexeme ID using the Beaver parser. 197 * @param symbol Symbol containing the new value for the lexeme ID 198 * @apilevel internal 199 */ 200 public void setID(beaver.Symbol symbol) { 201 if (symbol.value != null && !(symbol.value instanceof String)) 202 throw new UnsupportedOperationException("setID is only valid for String lexemes"); 203 tokenString_ID = (String)symbol.value; 204 IDstart = symbol.getStart(); 205 IDend = symbol.getEnd(); 206 } 207 /** 208 * Retrieves the value for the lexeme ID. 209 * @return The value for the lexeme ID. 210 * @apilevel high-level 211 */ 212 @ASTNodeAnnotation.Token(name="ID") 213 public String getID() { 214 return tokenString_ID != null ? tokenString_ID : ""; 215 } 216 /** 217 * Replaces the Arg list. 218 * @param list The new list node to be used as the Arg list. 219 * @apilevel high-level 220 */ 221 public void setArgList(List<Expr> list) { 222 setChild(list, 0); 223 } 224 /** 225 * Retrieves the number of children in the Arg list. 226 * @return Number of children in the Arg list. 227 * @apilevel high-level 228 */ 229 public int getNumArg() { 230 return getArgList().getNumChild(); 231 } 232 /** 233 * Retrieves the number of children in the Arg list. 234 * Calling this method will not trigger rewrites. 235 * @return Number of children in the Arg list. 236 * @apilevel low-level 237 */ 238 public int getNumArgNoTransform() { 239 return getArgListNoTransform().getNumChildNoTransform(); 240 } 241 /** 242 * Retrieves the element at index {@code i} in the Arg list. 243 * @param i Index of the element to return. 244 * @return The element at position {@code i} in the Arg list. 245 * @apilevel high-level 246 */ 247 public Expr getArg(int i) { 248 return (Expr) getArgList().getChild(i); 249 } 250 /** 251 * Check whether the Arg list has any children. 252 * @return {@code true} if it has at least one child, {@code false} otherwise. 253 * @apilevel high-level 254 */ 255 public boolean hasArg() { 256 return getArgList().getNumChild() != 0; 257 } 258 /** 259 * Append an element to the Arg list. 260 * @param node The element to append to the Arg list. 261 * @apilevel high-level 262 */ 263 public void addArg(Expr node) { 264 List<Expr> list = (parent == null) ? getArgListNoTransform() : getArgList(); 265 list.addChild(node); 266 } 267 /** 268 * @apilevel low-level 269 */ 270 public void addArgNoTransform(Expr node) { 271 List<Expr> list = getArgListNoTransform(); 272 list.addChild(node); 273 } 274 /** 275 * Replaces the Arg list element at index {@code i} with the new node {@code node}. 276 * @param node The new node to replace the old list element. 277 * @param i The list index of the node to be replaced. 278 * @apilevel high-level 279 */ 280 public void setArg(Expr node, int i) { 281 List<Expr> list = getArgList(); 282 list.setChild(node, i); 283 } 284 /** 285 * Retrieves the Arg list. 286 * @return The node representing the Arg list. 287 * @apilevel high-level 288 */ 289 @ASTNodeAnnotation.ListChild(name="Arg") 290 public List<Expr> getArgList() { 291 List<Expr> list = (List<Expr>) getChild(0); 292 return list; 293 } 294 /** 295 * Retrieves the Arg list. 296 * <p><em>This method does not invoke AST transformations.</em></p> 297 * @return The node representing the Arg list. 298 * @apilevel low-level 299 */ 300 public List<Expr> getArgListNoTransform() { 301 return (List<Expr>) getChildNoTransform(0); 302 } 303 /** 304 * Retrieves the Arg list. 305 * @return The node representing the Arg list. 306 * @apilevel high-level 307 */ 308 public List<Expr> getArgs() { 309 return getArgList(); 310 } 311 /** 312 * Retrieves the Arg list. 313 * <p><em>This method does not invoke AST transformations.</em></p> 314 * @return The node representing the Arg list. 315 * @apilevel low-level 316 */ 317 public List<Expr> getArgsNoTransform() { 318 return getArgListNoTransform(); 319 } 320 /** 321 * @apilevel internal 322 */ 323 protected boolean assignConvertedType_computed = false; 324 /** 325 * @apilevel internal 326 */ 327 protected TypeDecl assignConvertedType_value; 328 /** 329 * @apilevel internal 330 */ 331 private void assignConvertedType_reset() { 332 assignConvertedType_computed = false; 333 assignConvertedType_value = null; 334 } 335 /** 336 * @attribute syn 337 * @aspect TargetType 338 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:174 339 */ 340 @ASTNodeAnnotation.Attribute 341 public TypeDecl assignConvertedType() { 342 ASTNode$State state = state(); 343 if (assignConvertedType_computed) { 344 return assignConvertedType_value; 345 } 346 boolean intermediate = state.INTERMEDIATE_VALUE; 347 state.INTERMEDIATE_VALUE = false; 348 int num = state.boundariesCrossed; 349 boolean isFinal = this.is$Final(); 350 assignConvertedType_value = targetDescriptor.method.type(); 351 if (isFinal && num == state().boundariesCrossed) { 352 assignConvertedType_computed = true; 353 } else { 354 } 355 state.INTERMEDIATE_VALUE |= intermediate; 356 357 return assignConvertedType_value; 358 } 359 /** 360 * @apilevel internal 361 */ 362 public ASTNode rewriteTo() { 363 return super.rewriteTo(); 364 } 365 }