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/Annotations.ast:13 027 * @production ElementArrayValue : {@link ElementValue} ::= <span class="component">{@link ElementValue}*</span>; 028 029 */ 030 public class ElementArrayValue extends ElementValue implements Cloneable { 031 /** 032 * @aspect Java5PrettyPrint 033 * @declaredat /home/jesper/git/extendj/java5/frontend/PrettyPrint.jadd:155 034 */ 035 public void prettyPrint(PrettyPrinter out) { 036 out.print("{ "); 037 out.join(getElementValueList(), new PrettyPrinter.Joiner() { 038 @Override 039 public void printSeparator(PrettyPrinter out) { 040 out.print(", "); 041 } 042 }); 043 out.print(" }"); 044 } 045 /** 046 * @aspect AnnotationsCodegen 047 * @declaredat /home/jesper/git/extendj/java5/backend/AnnotationsCodegen.jrag:284 048 */ 049 public void appendAsAttributeTo(Attribute buf) { 050 buf.u1('['); 051 buf.u2(getNumElementValue()); 052 for (int i = 0; i < getNumElementValue(); i++) { 053 getElementValue(i).appendAsAttributeTo(buf); 054 } 055 } 056 /** 057 * @declaredat ASTNode:1 058 */ 059 public ElementArrayValue() { 060 super(); 061 } 062 /** 063 * Initializes the child array to the correct size. 064 * Initializes List and Opt nta children. 065 * @apilevel internal 066 * @ast method 067 * @declaredat ASTNode:10 068 */ 069 public void init$Children() { 070 children = new ASTNode[1]; 071 setChild(new List(), 0); 072 } 073 /** 074 * @declaredat ASTNode:14 075 */ 076 public ElementArrayValue(List<ElementValue> p0) { 077 setChild(p0, 0); 078 } 079 /** 080 * @apilevel low-level 081 * @declaredat ASTNode:20 082 */ 083 protected int numChildren() { 084 return 1; 085 } 086 /** 087 * @apilevel internal 088 * @declaredat ASTNode:26 089 */ 090 public boolean mayHaveRewrite() { 091 return false; 092 } 093 /** 094 * @apilevel internal 095 * @declaredat ASTNode:32 096 */ 097 public void flushAttrCache() { 098 super.flushAttrCache(); 099 } 100 /** 101 * @apilevel internal 102 * @declaredat ASTNode:38 103 */ 104 public void flushCollectionCache() { 105 super.flushCollectionCache(); 106 } 107 /** 108 * @apilevel internal 109 * @declaredat ASTNode:44 110 */ 111 public void flushRewriteCache() { 112 super.flushRewriteCache(); 113 } 114 /** 115 * @apilevel internal 116 * @declaredat ASTNode:50 117 */ 118 public ElementArrayValue clone() throws CloneNotSupportedException { 119 ElementArrayValue node = (ElementArrayValue) super.clone(); 120 return node; 121 } 122 /** 123 * @apilevel internal 124 * @declaredat ASTNode:57 125 */ 126 public ElementArrayValue copy() { 127 try { 128 ElementArrayValue node = (ElementArrayValue) clone(); 129 node.parent = null; 130 if (children != null) { 131 node.children = (ASTNode[]) children.clone(); 132 } 133 return node; 134 } catch (CloneNotSupportedException e) { 135 throw new Error("Error: clone not supported for " + getClass().getName()); 136 } 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 * @deprecated Please use treeCopy or treeCopyNoTransform instead 144 * @declaredat ASTNode:76 145 */ 146 @Deprecated 147 public ElementArrayValue fullCopy() { 148 return treeCopyNoTransform(); 149 } 150 /** 151 * Create a deep copy of the AST subtree at this node. 152 * The copy is dangling, i.e. has no parent. 153 * @return dangling copy of the subtree at this node 154 * @apilevel low-level 155 * @declaredat ASTNode:86 156 */ 157 public ElementArrayValue treeCopyNoTransform() { 158 ElementArrayValue tree = (ElementArrayValue) copy(); 159 if (children != null) { 160 for (int i = 0; i < children.length; ++i) { 161 ASTNode child = (ASTNode) children[i]; 162 if (child != null) { 163 child = child.treeCopyNoTransform(); 164 tree.setChild(child, i); 165 } 166 } 167 } 168 return tree; 169 } 170 /** 171 * Create a deep copy of the AST subtree at this node. 172 * The subtree of this node is traversed to trigger rewrites before copy. 173 * The copy is dangling, i.e. has no parent. 174 * @return dangling copy of the subtree at this node 175 * @apilevel low-level 176 * @declaredat ASTNode:106 177 */ 178 public ElementArrayValue treeCopy() { 179 doFullTraversal(); 180 return treeCopyNoTransform(); 181 } 182 /** 183 * @apilevel internal 184 * @declaredat ASTNode:113 185 */ 186 protected boolean is$Equal(ASTNode node) { 187 return super.is$Equal(node); 188 } 189 /** 190 * Replaces the ElementValue list. 191 * @param list The new list node to be used as the ElementValue list. 192 * @apilevel high-level 193 */ 194 public void setElementValueList(List<ElementValue> list) { 195 setChild(list, 0); 196 } 197 /** 198 * Retrieves the number of children in the ElementValue list. 199 * @return Number of children in the ElementValue list. 200 * @apilevel high-level 201 */ 202 public int getNumElementValue() { 203 return getElementValueList().getNumChild(); 204 } 205 /** 206 * Retrieves the number of children in the ElementValue list. 207 * Calling this method will not trigger rewrites. 208 * @return Number of children in the ElementValue list. 209 * @apilevel low-level 210 */ 211 public int getNumElementValueNoTransform() { 212 return getElementValueListNoTransform().getNumChildNoTransform(); 213 } 214 /** 215 * Retrieves the element at index {@code i} in the ElementValue list. 216 * @param i Index of the element to return. 217 * @return The element at position {@code i} in the ElementValue list. 218 * @apilevel high-level 219 */ 220 public ElementValue getElementValue(int i) { 221 return (ElementValue) getElementValueList().getChild(i); 222 } 223 /** 224 * Check whether the ElementValue list has any children. 225 * @return {@code true} if it has at least one child, {@code false} otherwise. 226 * @apilevel high-level 227 */ 228 public boolean hasElementValue() { 229 return getElementValueList().getNumChild() != 0; 230 } 231 /** 232 * Append an element to the ElementValue list. 233 * @param node The element to append to the ElementValue list. 234 * @apilevel high-level 235 */ 236 public void addElementValue(ElementValue node) { 237 List<ElementValue> list = (parent == null) ? getElementValueListNoTransform() : getElementValueList(); 238 list.addChild(node); 239 } 240 /** 241 * @apilevel low-level 242 */ 243 public void addElementValueNoTransform(ElementValue node) { 244 List<ElementValue> list = getElementValueListNoTransform(); 245 list.addChild(node); 246 } 247 /** 248 * Replaces the ElementValue list element at index {@code i} with the new node {@code node}. 249 * @param node The new node to replace the old list element. 250 * @param i The list index of the node to be replaced. 251 * @apilevel high-level 252 */ 253 public void setElementValue(ElementValue node, int i) { 254 List<ElementValue> list = getElementValueList(); 255 list.setChild(node, i); 256 } 257 /** 258 * Retrieves the ElementValue list. 259 * @return The node representing the ElementValue list. 260 * @apilevel high-level 261 */ 262 @ASTNodeAnnotation.ListChild(name="ElementValue") 263 public List<ElementValue> getElementValueList() { 264 List<ElementValue> list = (List<ElementValue>) getChild(0); 265 return list; 266 } 267 /** 268 * Retrieves the ElementValue list. 269 * <p><em>This method does not invoke AST transformations.</em></p> 270 * @return The node representing the ElementValue list. 271 * @apilevel low-level 272 */ 273 public List<ElementValue> getElementValueListNoTransform() { 274 return (List<ElementValue>) getChildNoTransform(0); 275 } 276 /** 277 * Retrieves the ElementValue list. 278 * @return The node representing the ElementValue list. 279 * @apilevel high-level 280 */ 281 public List<ElementValue> getElementValues() { 282 return getElementValueList(); 283 } 284 /** 285 * Retrieves the ElementValue list. 286 * <p><em>This method does not invoke AST transformations.</em></p> 287 * @return The node representing the ElementValue list. 288 * @apilevel low-level 289 */ 290 public List<ElementValue> getElementValuesNoTransform() { 291 return getElementValueListNoTransform(); 292 } 293 /** 294 * @attribute syn 295 * @aspect Annotations 296 * @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:80 297 */ 298 @ASTNodeAnnotation.Attribute 299 public boolean validTarget(Annotation a) { 300 { 301 for (int i = 0; i < getNumElementValue(); i++) { 302 if (getElementValue(i).validTarget(a)) { 303 return true; 304 } 305 } 306 return false; 307 } 308 } 309 /** 310 * @attribute syn 311 * @aspect Annotations 312 * @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:228 313 */ 314 @ASTNodeAnnotation.Attribute 315 public ElementValue definesElementTypeValue(String name) { 316 { 317 for (int i = 0; i < getNumElementValue(); i++) { 318 if (getElementValue(i).definesElementTypeValue(name) != null) { 319 return getElementValue(i).definesElementTypeValue(name); 320 } 321 } 322 return null; 323 } 324 } 325 /** 326 * @attribute syn 327 * @aspect Annotations 328 * @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:370 329 */ 330 @ASTNodeAnnotation.Attribute 331 public boolean hasValue(String annot) { 332 { 333 for (int i = 0; i < getNumElementValue(); i++) { 334 if (getElementValue(i).hasValue(annot)) { 335 return true; 336 } 337 } 338 return false; 339 } 340 } 341 /** 342 * @attribute syn 343 * @aspect Annotations 344 * @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:583 345 */ 346 @ASTNodeAnnotation.Attribute 347 public boolean commensurateWithArrayDecl(ArrayDecl type) { 348 { 349 for (int i = 0; i < getNumElementValue(); i++) { 350 if (!type.componentType().commensurateWith(getElementValue(i))) { 351 return false; 352 } 353 } 354 return true; 355 } 356 } 357 /** 358 * @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:224 359 * @apilevel internal 360 */ 361 public ElementValue Define_lookupElementTypeValue(ASTNode caller, ASTNode child, String name) { 362 if (caller == getElementValueListNoTransform()) { 363 // @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:225 364 int childIndex = caller.getIndexOfChild(child); 365 return definesElementTypeValue(name); 366 } 367 else { 368 return getParent().Define_lookupElementTypeValue(this, caller, name); 369 } 370 } 371 protected boolean canDefine_lookupElementTypeValue(ASTNode caller, ASTNode child, String name) { 372 return true; 373 } 374 /** 375 * @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:601 376 * @apilevel internal 377 */ 378 public TypeDecl Define_declType(ASTNode caller, ASTNode child) { 379 int childIndex = this.getIndexOfChild(caller); 380 return declType().elementType(); 381 } 382 protected boolean canDefine_declType(ASTNode caller, ASTNode child) { 383 return true; 384 } 385 /** 386 * @apilevel internal 387 */ 388 public ASTNode rewriteTo() { 389 return super.rewriteTo(); 390 } 391 }