001 /* This file was generated with JastAdd2 (http://jastadd.org) version R20130213 */ 002 package AST; 003 004 import java.util.HashSet; 005 import java.io.File; 006 import java.util.*; 007 import beaver.*; 008 import java.util.ArrayList; 009 import java.util.zip.*; 010 import java.io.*; 011 import java.io.FileNotFoundException; 012 import java.util.Collection; 013 /** 014 * @production FieldDecl : {@link MemberDecl} ::= <span class="component">{@link Modifiers}</span> <span class="component">TypeAccess:{@link Access}</span> <span class="component">{@link VariableDecl}*</span>; 015 * @ast node 016 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/java.ast:79 017 */ 018 public class FieldDecl extends MemberDecl implements Cloneable { 019 /** 020 * @apilevel low-level 021 */ 022 public void flushCache() { 023 } 024 /** 025 * @apilevel internal 026 */ 027 public void flushCollectionCache() { 028 } 029 /** 030 * @apilevel internal 031 */ 032 @SuppressWarnings({"unchecked", "cast"}) 033 public FieldDecl clone() throws CloneNotSupportedException { 034 FieldDecl node = (FieldDecl)super.clone(); 035 node.in$Circle(false); 036 node.is$Final(false); 037 return node; 038 } 039 /** 040 * @apilevel internal 041 */ 042 @SuppressWarnings({"unchecked", "cast"}) 043 public FieldDecl copy() { 044 045 try { 046 FieldDecl node = (FieldDecl) clone(); 047 node.parent = null; 048 if(children != null) 049 node.children = (ASTNode[]) children.clone(); 050 051 return node; 052 } catch (CloneNotSupportedException e) { 053 throw new Error("Error: clone not supported for " + getClass().getName()); 054 } 055 056 }/** 057 * Create a deep copy of the AST subtree at this node. 058 * The copy is dangling, i.e. has no parent. 059 * @return dangling copy of the subtree at this node 060 * @apilevel low-level 061 */ 062 @SuppressWarnings({"unchecked", "cast"}) 063 public FieldDecl fullCopy() { 064 065 FieldDecl tree = (FieldDecl) copy(); 066 if (children != null) { 067 for (int i = 0; i < children.length; ++i) { 068 069 ASTNode child = (ASTNode) children[i]; 070 if(child != null) { 071 child = child.fullCopy(); 072 tree.setChild(child, i); 073 } 074 } 075 } 076 return tree; 077 078 } /** 079 * @ast method 080 * 081 */ 082 public FieldDecl() { 083 super(); 084 085 086 } 087 /** 088 * Initializes the child array to the correct size. 089 * Initializes List and Opt nta children. 090 * @apilevel internal 091 * @ast method 092 * @ast method 093 * 094 */ 095 public void init$Children() { 096 children = new ASTNode[3]; 097 setChild(new List(), 2); 098 } 099 /** 100 * @ast method 101 * 102 */ 103 public FieldDecl(Modifiers p0, Access p1, List<VariableDecl> p2) { 104 setChild(p0, 0); 105 setChild(p1, 1); 106 setChild(p2, 2); 107 } 108 /** 109 * @apilevel low-level 110 * @ast method 111 * 112 */ 113 protected int numChildren() { 114 return 3; 115 } 116 /** 117 * @apilevel internal 118 * @ast method 119 * 120 */ 121 public boolean mayHaveRewrite() { 122 return true; 123 } 124 /** 125 * Replaces the Modifiers child. 126 * @param node The new node to replace the Modifiers child. 127 * @apilevel high-level 128 * @ast method 129 * 130 */ 131 public void setModifiers(Modifiers node) { 132 setChild(node, 0); 133 } 134 /** 135 * Retrieves the Modifiers child. 136 * @return The current node used as the Modifiers child. 137 * @apilevel high-level 138 * @ast method 139 * 140 */ 141 public Modifiers getModifiers() { 142 return (Modifiers)getChild(0); 143 } 144 /** 145 * Retrieves the Modifiers child. 146 * <p><em>This method does not invoke AST transformations.</em></p> 147 * @return The current node used as the Modifiers child. 148 * @apilevel low-level 149 * @ast method 150 * 151 */ 152 public Modifiers getModifiersNoTransform() { 153 return (Modifiers)getChildNoTransform(0); 154 } 155 /** 156 * Replaces the TypeAccess child. 157 * @param node The new node to replace the TypeAccess child. 158 * @apilevel high-level 159 * @ast method 160 * 161 */ 162 public void setTypeAccess(Access node) { 163 setChild(node, 1); 164 } 165 /** 166 * Retrieves the TypeAccess child. 167 * @return The current node used as the TypeAccess child. 168 * @apilevel high-level 169 * @ast method 170 * 171 */ 172 public Access getTypeAccess() { 173 return (Access)getChild(1); 174 } 175 /** 176 * Retrieves the TypeAccess child. 177 * <p><em>This method does not invoke AST transformations.</em></p> 178 * @return The current node used as the TypeAccess child. 179 * @apilevel low-level 180 * @ast method 181 * 182 */ 183 public Access getTypeAccessNoTransform() { 184 return (Access)getChildNoTransform(1); 185 } 186 /** 187 * Replaces the VariableDecl list. 188 * @param list The new list node to be used as the VariableDecl list. 189 * @apilevel high-level 190 * @ast method 191 * 192 */ 193 public void setVariableDeclList(List<VariableDecl> list) { 194 setChild(list, 2); 195 } 196 /** 197 * Retrieves the number of children in the VariableDecl list. 198 * @return Number of children in the VariableDecl list. 199 * @apilevel high-level 200 * @ast method 201 * 202 */ 203 public int getNumVariableDecl() { 204 return getVariableDeclList().getNumChild(); 205 } 206 /** 207 * Retrieves the number of children in the VariableDecl list. 208 * Calling this method will not trigger rewrites.. 209 * @return Number of children in the VariableDecl list. 210 * @apilevel low-level 211 * @ast method 212 * 213 */ 214 public int getNumVariableDeclNoTransform() { 215 return getVariableDeclListNoTransform().getNumChildNoTransform(); 216 } 217 /** 218 * Retrieves the element at index {@code i} in the VariableDecl list.. 219 * @param i Index of the element to return. 220 * @return The element at position {@code i} in the VariableDecl list. 221 * @apilevel high-level 222 * @ast method 223 * 224 */ 225 @SuppressWarnings({"unchecked", "cast"}) 226 public VariableDecl getVariableDecl(int i) { 227 return (VariableDecl)getVariableDeclList().getChild(i); 228 } 229 /** 230 * Append an element to the VariableDecl list. 231 * @param node The element to append to the VariableDecl list. 232 * @apilevel high-level 233 * @ast method 234 * 235 */ 236 public void addVariableDecl(VariableDecl node) { 237 List<VariableDecl> list = (parent == null || state == null) ? getVariableDeclListNoTransform() : getVariableDeclList(); 238 list.addChild(node); 239 } 240 /** 241 * @apilevel low-level 242 * @ast method 243 * 244 */ 245 public void addVariableDeclNoTransform(VariableDecl node) { 246 List<VariableDecl> list = getVariableDeclListNoTransform(); 247 list.addChild(node); 248 } 249 /** 250 * Replaces the VariableDecl list element at index {@code i} with the new node {@code node}. 251 * @param node The new node to replace the old list element. 252 * @param i The list index of the node to be replaced. 253 * @apilevel high-level 254 * @ast method 255 * 256 */ 257 public void setVariableDecl(VariableDecl node, int i) { 258 List<VariableDecl> list = getVariableDeclList(); 259 list.setChild(node, i); 260 } 261 /** 262 * Retrieves the VariableDecl list. 263 * @return The node representing the VariableDecl list. 264 * @apilevel high-level 265 * @ast method 266 * 267 */ 268 public List<VariableDecl> getVariableDecls() { 269 return getVariableDeclList(); 270 } 271 /** 272 * Retrieves the VariableDecl list. 273 * <p><em>This method does not invoke AST transformations.</em></p> 274 * @return The node representing the VariableDecl list. 275 * @apilevel low-level 276 * @ast method 277 * 278 */ 279 public List<VariableDecl> getVariableDeclsNoTransform() { 280 return getVariableDeclListNoTransform(); 281 } 282 /** 283 * Retrieves the VariableDecl list. 284 * @return The node representing the VariableDecl list. 285 * @apilevel high-level 286 * @ast method 287 * 288 */ 289 @SuppressWarnings({"unchecked", "cast"}) 290 public List<VariableDecl> getVariableDeclList() { 291 List<VariableDecl> list = (List<VariableDecl>)getChild(2); 292 list.getNumChild(); 293 return list; 294 } 295 /** 296 * Retrieves the VariableDecl list. 297 * <p><em>This method does not invoke AST transformations.</em></p> 298 * @return The node representing the VariableDecl list. 299 * @apilevel low-level 300 * @ast method 301 * 302 */ 303 @SuppressWarnings({"unchecked", "cast"}) 304 public List<VariableDecl> getVariableDeclListNoTransform() { 305 return (List<VariableDecl>)getChildNoTransform(2); 306 } 307 /** 308 * @attribute syn 309 * @aspect Modifiers 310 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/Modifiers.jrag:243 311 */ 312 public boolean isStatic() { 313 ASTNode$State state = state(); 314 try { return getModifiers().isStatic(); } 315 finally { 316 } 317 } 318 /** 319 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/SyntacticClassification.jrag:77 320 * @apilevel internal 321 */ 322 public NameType Define_NameType_nameType(ASTNode caller, ASTNode child) { 323 if(caller == getTypeAccessNoTransform()) { 324 return NameType.TYPE_NAME; 325 } 326 else { return getParent().Define_NameType_nameType(this, caller); 327 } 328 } 329 /** 330 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:257 331 * @apilevel internal 332 */ 333 public TypeDecl Define_TypeDecl_declType(ASTNode caller, ASTNode child) { 334 if(caller == getVariableDeclListNoTransform()) { 335 int childIndex = caller.getIndexOfChild(child); 336 return null; 337 } 338 else { return getParent().Define_TypeDecl_declType(this, caller); 339 } 340 } 341 /** 342 * @apilevel internal 343 */ 344 public ASTNode rewriteTo() { 345 // Declared in /home/jesper/svn/JastAddJ/Java1.4Frontend/VariableDeclaration.jrag at line 101 346 if(getNumVariableDecl() == 1) { 347 state().duringVariableDeclarationTransformation++; 348 ASTNode result = rewriteRule0(); 349 state().duringVariableDeclarationTransformation--; 350 return result; 351 } 352 353 // Declared in /home/jesper/svn/JastAddJ/Java1.4Frontend/VariableDeclaration.jrag at line 112 354 if(getParent().getParent() instanceof TypeDecl && 355 ((TypeDecl)getParent().getParent()).getBodyDeclListNoTransform() == getParent() && getNumVariableDecl() > 1) { 356 state().duringVariableDeclarationTransformation++; 357 List list = (List)getParent(); 358 int i = list.getIndexOfChild(this); 359 List newList = rewriteTypeDecl_getBodyDecl(); 360 for(int j = 1; j < newList.getNumChildNoTransform(); j++) 361 list.insertChild(newList.getChildNoTransform(j), ++i); 362 state().duringVariableDeclarationTransformation--; 363 return newList.getChildNoTransform(0); 364 } 365 return super.rewriteTo(); 366 } 367 /** 368 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/VariableDeclaration.jrag:101 369 * @apilevel internal 370 */ private FieldDeclaration rewriteRule0() { 371 { 372 FieldDeclaration decl = getVariableDecl(0).createFieldDeclarationFrom(getModifiers(), getTypeAccess()); 373 decl.setStart(start); // copy location information 374 decl.setEnd(end); // copy location information 375 return decl; 376 } } 377 /** 378 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/VariableDeclaration.jrag:112 379 * @apilevel internal 380 */ private List rewriteTypeDecl_getBodyDecl() { 381 { 382 List varList = new List(); 383 for(int j = 0; j < getNumVariableDecl(); j++) { 384 FieldDeclaration f = 385 getVariableDecl(j).createFieldDeclarationFrom( 386 (Modifiers)getModifiers().fullCopy(), 387 (Access)getTypeAccess().fullCopy() 388 ); 389 if(j == 0) 390 f.setStart(start); 391 else { 392 f.getModifiersNoTransform().clearLocations(); 393 f.getTypeAccessNoTransform().clearLocations(); 394 } 395 f.setFieldDecl(this); 396 varList.add(f); 397 } 398 return varList; 399 } } 400 }