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/java5/grammar/Generics.ast:32 027 * @production FieldDeclarationSubstituted : {@link FieldDeclaration} ::= <span class="component"><Original:FieldDeclaration></span>; 028 029 */ 030 public class FieldDeclarationSubstituted extends FieldDeclaration implements Cloneable { 031 /** 032 * @declaredat ASTNode:1 033 */ 034 public FieldDeclarationSubstituted() { 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[3]; 046 setChild(new Opt(), 2); 047 } 048 /** 049 * @declaredat ASTNode:14 050 */ 051 public FieldDeclarationSubstituted(Modifiers p0, Access p1, String p2, Opt<Expr> p3, FieldDeclaration p4) { 052 setChild(p0, 0); 053 setChild(p1, 1); 054 setID(p2); 055 setChild(p3, 2); 056 setOriginal(p4); 057 } 058 /** 059 * @declaredat ASTNode:21 060 */ 061 public FieldDeclarationSubstituted(Modifiers p0, Access p1, beaver.Symbol p2, Opt<Expr> p3, FieldDeclaration p4) { 062 setChild(p0, 0); 063 setChild(p1, 1); 064 setID(p2); 065 setChild(p3, 2); 066 setOriginal(p4); 067 } 068 /** 069 * @apilevel low-level 070 * @declaredat ASTNode:31 071 */ 072 protected int numChildren() { 073 return 3; 074 } 075 /** 076 * @apilevel internal 077 * @declaredat ASTNode:37 078 */ 079 public boolean mayHaveRewrite() { 080 return false; 081 } 082 /** 083 * @apilevel internal 084 * @declaredat ASTNode:43 085 */ 086 public void flushAttrCache() { 087 super.flushAttrCache(); 088 sourceVariableDecl_reset(); 089 } 090 /** 091 * @apilevel internal 092 * @declaredat ASTNode:50 093 */ 094 public void flushCollectionCache() { 095 super.flushCollectionCache(); 096 } 097 /** 098 * @apilevel internal 099 * @declaredat ASTNode:56 100 */ 101 public void flushRewriteCache() { 102 super.flushRewriteCache(); 103 } 104 /** 105 * @apilevel internal 106 * @declaredat ASTNode:62 107 */ 108 public FieldDeclarationSubstituted clone() throws CloneNotSupportedException { 109 FieldDeclarationSubstituted node = (FieldDeclarationSubstituted) super.clone(); 110 return node; 111 } 112 /** 113 * @apilevel internal 114 * @declaredat ASTNode:69 115 */ 116 public FieldDeclarationSubstituted copy() { 117 try { 118 FieldDeclarationSubstituted node = (FieldDeclarationSubstituted) clone(); 119 node.parent = null; 120 if (children != null) { 121 node.children = (ASTNode[]) children.clone(); 122 } 123 return node; 124 } catch (CloneNotSupportedException e) { 125 throw new Error("Error: clone not supported for " + getClass().getName()); 126 } 127 } 128 /** 129 * Create a deep copy of the AST subtree at this node. 130 * The copy is dangling, i.e. has no parent. 131 * @return dangling copy of the subtree at this node 132 * @apilevel low-level 133 * @deprecated Please use treeCopy or treeCopyNoTransform instead 134 * @declaredat ASTNode:88 135 */ 136 @Deprecated 137 public FieldDeclarationSubstituted fullCopy() { 138 return treeCopyNoTransform(); 139 } 140 /** 141 * Create a deep copy of the AST subtree at this node. 142 * The copy is dangling, i.e. has no parent. 143 * @return dangling copy of the subtree at this node 144 * @apilevel low-level 145 * @declaredat ASTNode:98 146 */ 147 public FieldDeclarationSubstituted treeCopyNoTransform() { 148 FieldDeclarationSubstituted tree = (FieldDeclarationSubstituted) copy(); 149 if (children != null) { 150 for (int i = 0; i < children.length; ++i) { 151 ASTNode child = (ASTNode) children[i]; 152 if (child != null) { 153 child = child.treeCopyNoTransform(); 154 tree.setChild(child, i); 155 } 156 } 157 } 158 return tree; 159 } 160 /** 161 * Create a deep copy of the AST subtree at this node. 162 * The subtree of this node is traversed to trigger rewrites before copy. 163 * The copy is dangling, i.e. has no parent. 164 * @return dangling copy of the subtree at this node 165 * @apilevel low-level 166 * @declaredat ASTNode:118 167 */ 168 public FieldDeclarationSubstituted treeCopy() { 169 doFullTraversal(); 170 return treeCopyNoTransform(); 171 } 172 /** 173 * @apilevel internal 174 * @declaredat ASTNode:125 175 */ 176 protected boolean is$Equal(ASTNode node) { 177 return super.is$Equal(node) && (tokenString_ID == ((FieldDeclarationSubstituted)node).tokenString_ID) && (tokenFieldDeclaration_Original == ((FieldDeclarationSubstituted)node).tokenFieldDeclaration_Original); 178 } 179 /** 180 * Replaces the Modifiers child. 181 * @param node The new node to replace the Modifiers child. 182 * @apilevel high-level 183 */ 184 public void setModifiers(Modifiers node) { 185 setChild(node, 0); 186 } 187 /** 188 * Retrieves the Modifiers child. 189 * @return The current node used as the Modifiers child. 190 * @apilevel high-level 191 */ 192 @ASTNodeAnnotation.Child(name="Modifiers") 193 public Modifiers getModifiers() { 194 return (Modifiers) getChild(0); 195 } 196 /** 197 * Retrieves the Modifiers child. 198 * <p><em>This method does not invoke AST transformations.</em></p> 199 * @return The current node used as the Modifiers child. 200 * @apilevel low-level 201 */ 202 public Modifiers getModifiersNoTransform() { 203 return (Modifiers) getChildNoTransform(0); 204 } 205 /** 206 * Replaces the TypeAccess child. 207 * @param node The new node to replace the TypeAccess child. 208 * @apilevel high-level 209 */ 210 public void setTypeAccess(Access node) { 211 setChild(node, 1); 212 } 213 /** 214 * Retrieves the TypeAccess child. 215 * @return The current node used as the TypeAccess child. 216 * @apilevel high-level 217 */ 218 @ASTNodeAnnotation.Child(name="TypeAccess") 219 public Access getTypeAccess() { 220 return (Access) getChild(1); 221 } 222 /** 223 * Retrieves the TypeAccess child. 224 * <p><em>This method does not invoke AST transformations.</em></p> 225 * @return The current node used as the TypeAccess child. 226 * @apilevel low-level 227 */ 228 public Access getTypeAccessNoTransform() { 229 return (Access) getChildNoTransform(1); 230 } 231 /** 232 * Replaces the lexeme ID. 233 * @param value The new value for the lexeme ID. 234 * @apilevel high-level 235 */ 236 public void setID(String value) { 237 tokenString_ID = value; 238 } 239 /** 240 * JastAdd-internal setter for lexeme ID using the Beaver parser. 241 * @param symbol Symbol containing the new value for the lexeme ID 242 * @apilevel internal 243 */ 244 public void setID(beaver.Symbol symbol) { 245 if (symbol.value != null && !(symbol.value instanceof String)) 246 throw new UnsupportedOperationException("setID is only valid for String lexemes"); 247 tokenString_ID = (String)symbol.value; 248 IDstart = symbol.getStart(); 249 IDend = symbol.getEnd(); 250 } 251 /** 252 * Retrieves the value for the lexeme ID. 253 * @return The value for the lexeme ID. 254 * @apilevel high-level 255 */ 256 @ASTNodeAnnotation.Token(name="ID") 257 public String getID() { 258 return tokenString_ID != null ? tokenString_ID : ""; 259 } 260 /** 261 * Replaces the optional node for the Init child. This is the <code>Opt</code> 262 * node containing the child Init, not the actual child! 263 * @param opt The new node to be used as the optional node for the Init child. 264 * @apilevel low-level 265 */ 266 public void setInitOpt(Opt<Expr> opt) { 267 setChild(opt, 2); 268 } 269 /** 270 * Replaces the (optional) Init child. 271 * @param node The new node to be used as the Init child. 272 * @apilevel high-level 273 */ 274 public void setInit(Expr node) { 275 getInitOpt().setChild(node, 0); 276 } 277 /** 278 * Check whether the optional Init child exists. 279 * @return {@code true} if the optional Init child exists, {@code false} if it does not. 280 * @apilevel high-level 281 */ 282 public boolean hasInit() { 283 return getInitOpt().getNumChild() != 0; 284 } 285 /** 286 * Retrieves the (optional) Init child. 287 * @return The Init child, if it exists. Returns {@code null} otherwise. 288 * @apilevel low-level 289 */ 290 public Expr getInit() { 291 return (Expr) getInitOpt().getChild(0); 292 } 293 /** 294 * Retrieves the optional node for the Init child. This is the <code>Opt</code> node containing the child Init, not the actual child! 295 * @return The optional node for child the Init child. 296 * @apilevel low-level 297 */ 298 @ASTNodeAnnotation.OptChild(name="Init") 299 public Opt<Expr> getInitOpt() { 300 return (Opt<Expr>) getChild(2); 301 } 302 /** 303 * Retrieves the optional node for child Init. This is the <code>Opt</code> node containing the child Init, not the actual child! 304 * <p><em>This method does not invoke AST transformations.</em></p> 305 * @return The optional node for child Init. 306 * @apilevel low-level 307 */ 308 public Opt<Expr> getInitOptNoTransform() { 309 return (Opt<Expr>) getChildNoTransform(2); 310 } 311 /** 312 * Replaces the lexeme Original. 313 * @param value The new value for the lexeme Original. 314 * @apilevel high-level 315 */ 316 public void setOriginal(FieldDeclaration value) { 317 tokenFieldDeclaration_Original = value; 318 } 319 /** 320 * @apilevel internal 321 */ 322 protected FieldDeclaration tokenFieldDeclaration_Original; 323 /** 324 * Retrieves the value for the lexeme Original. 325 * @return The value for the lexeme Original. 326 * @apilevel high-level 327 */ 328 @ASTNodeAnnotation.Token(name="Original") 329 public FieldDeclaration getOriginal() { 330 return tokenFieldDeclaration_Original; 331 } 332 /** 333 * @attribute syn 334 * @aspect LookupParTypeDecl 335 * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:1410 336 */ 337 @ASTNodeAnnotation.Attribute 338 public FieldDeclaration erasedField() { 339 FieldDeclaration erasedField_value = getOriginal().erasedField(); 340 341 return erasedField_value; 342 } 343 /** 344 * @apilevel internal 345 */ 346 protected boolean sourceVariableDecl_computed = false; 347 /** 348 * @apilevel internal 349 */ 350 protected Variable sourceVariableDecl_value; 351 /** 352 * @apilevel internal 353 */ 354 private void sourceVariableDecl_reset() { 355 sourceVariableDecl_computed = false; 356 sourceVariableDecl_value = null; 357 } 358 /** 359 * @attribute syn 360 * @aspect SourceDeclarations 361 * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:1637 362 */ 363 @ASTNodeAnnotation.Attribute 364 public Variable sourceVariableDecl() { 365 ASTNode$State state = state(); 366 if (sourceVariableDecl_computed) { 367 return sourceVariableDecl_value; 368 } 369 boolean intermediate = state.INTERMEDIATE_VALUE; 370 state.INTERMEDIATE_VALUE = false; 371 int num = state.boundariesCrossed; 372 boolean isFinal = this.is$Final(); 373 sourceVariableDecl_value = getOriginal().sourceVariableDecl(); 374 if (isFinal && num == state().boundariesCrossed) { 375 sourceVariableDecl_computed = true; 376 } else { 377 } 378 state.INTERMEDIATE_VALUE |= intermediate; 379 380 return sourceVariableDecl_value; 381 } 382 /** 383 * @apilevel internal 384 */ 385 public ASTNode rewriteTo() { 386 return super.rewriteTo(); 387 } 388 }