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 ElementArrayValue : {@link ElementValue} ::= <span class="component">{@link ElementValue}*</span>; 015 * @ast node 016 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Annotations.ast:13 017 */ 018 public class ElementArrayValue extends ElementValue 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 ElementArrayValue clone() throws CloneNotSupportedException { 034 ElementArrayValue node = (ElementArrayValue)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 ElementArrayValue copy() { 044 045 try { 046 ElementArrayValue node = (ElementArrayValue) 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 ElementArrayValue fullCopy() { 064 065 ElementArrayValue tree = (ElementArrayValue) 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 * @aspect Annotations 081 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Annotations.jrag:603 082 */ 083 public void toString(StringBuffer s) { 084 s.append("{"); 085 for(int i = 0; i < getNumElementValue(); i++) { 086 getElementValue(i).toString(s); 087 s.append(", "); 088 } 089 s.append("}"); 090 } 091 /** 092 * @ast method 093 * @aspect AnnotationsCodegen 094 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/AnnotationsCodegen.jrag:224 095 */ 096 public void appendAsAttributeTo(Attribute buf) { 097 buf.u1('['); 098 buf.u2(getNumElementValue()); 099 for(int i = 0; i < getNumElementValue(); i++) 100 getElementValue(i).appendAsAttributeTo(buf); 101 } 102 /** 103 * @ast method 104 * 105 */ 106 public ElementArrayValue() { 107 super(); 108 109 110 } 111 /** 112 * Initializes the child array to the correct size. 113 * Initializes List and Opt nta children. 114 * @apilevel internal 115 * @ast method 116 * @ast method 117 * 118 */ 119 public void init$Children() { 120 children = new ASTNode[1]; 121 setChild(new List(), 0); 122 } 123 /** 124 * @ast method 125 * 126 */ 127 public ElementArrayValue(List<ElementValue> p0) { 128 setChild(p0, 0); 129 } 130 /** 131 * @apilevel low-level 132 * @ast method 133 * 134 */ 135 protected int numChildren() { 136 return 1; 137 } 138 /** 139 * @apilevel internal 140 * @ast method 141 * 142 */ 143 public boolean mayHaveRewrite() { 144 return false; 145 } 146 /** 147 * Replaces the ElementValue list. 148 * @param list The new list node to be used as the ElementValue list. 149 * @apilevel high-level 150 * @ast method 151 * 152 */ 153 public void setElementValueList(List<ElementValue> list) { 154 setChild(list, 0); 155 } 156 /** 157 * Retrieves the number of children in the ElementValue list. 158 * @return Number of children in the ElementValue list. 159 * @apilevel high-level 160 * @ast method 161 * 162 */ 163 public int getNumElementValue() { 164 return getElementValueList().getNumChild(); 165 } 166 /** 167 * Retrieves the number of children in the ElementValue list. 168 * Calling this method will not trigger rewrites.. 169 * @return Number of children in the ElementValue list. 170 * @apilevel low-level 171 * @ast method 172 * 173 */ 174 public int getNumElementValueNoTransform() { 175 return getElementValueListNoTransform().getNumChildNoTransform(); 176 } 177 /** 178 * Retrieves the element at index {@code i} in the ElementValue list.. 179 * @param i Index of the element to return. 180 * @return The element at position {@code i} in the ElementValue list. 181 * @apilevel high-level 182 * @ast method 183 * 184 */ 185 @SuppressWarnings({"unchecked", "cast"}) 186 public ElementValue getElementValue(int i) { 187 return (ElementValue)getElementValueList().getChild(i); 188 } 189 /** 190 * Append an element to the ElementValue list. 191 * @param node The element to append to the ElementValue list. 192 * @apilevel high-level 193 * @ast method 194 * 195 */ 196 public void addElementValue(ElementValue node) { 197 List<ElementValue> list = (parent == null || state == null) ? getElementValueListNoTransform() : getElementValueList(); 198 list.addChild(node); 199 } 200 /** 201 * @apilevel low-level 202 * @ast method 203 * 204 */ 205 public void addElementValueNoTransform(ElementValue node) { 206 List<ElementValue> list = getElementValueListNoTransform(); 207 list.addChild(node); 208 } 209 /** 210 * Replaces the ElementValue list element at index {@code i} with the new node {@code node}. 211 * @param node The new node to replace the old list element. 212 * @param i The list index of the node to be replaced. 213 * @apilevel high-level 214 * @ast method 215 * 216 */ 217 public void setElementValue(ElementValue node, int i) { 218 List<ElementValue> list = getElementValueList(); 219 list.setChild(node, i); 220 } 221 /** 222 * Retrieves the ElementValue list. 223 * @return The node representing the ElementValue list. 224 * @apilevel high-level 225 * @ast method 226 * 227 */ 228 public List<ElementValue> getElementValues() { 229 return getElementValueList(); 230 } 231 /** 232 * Retrieves the ElementValue list. 233 * <p><em>This method does not invoke AST transformations.</em></p> 234 * @return The node representing the ElementValue list. 235 * @apilevel low-level 236 * @ast method 237 * 238 */ 239 public List<ElementValue> getElementValuesNoTransform() { 240 return getElementValueListNoTransform(); 241 } 242 /** 243 * Retrieves the ElementValue list. 244 * @return The node representing the ElementValue list. 245 * @apilevel high-level 246 * @ast method 247 * 248 */ 249 @SuppressWarnings({"unchecked", "cast"}) 250 public List<ElementValue> getElementValueList() { 251 List<ElementValue> list = (List<ElementValue>)getChild(0); 252 list.getNumChild(); 253 return list; 254 } 255 /** 256 * Retrieves the ElementValue list. 257 * <p><em>This method does not invoke AST transformations.</em></p> 258 * @return The node representing the ElementValue list. 259 * @apilevel low-level 260 * @ast method 261 * 262 */ 263 @SuppressWarnings({"unchecked", "cast"}) 264 public List<ElementValue> getElementValueListNoTransform() { 265 return (List<ElementValue>)getChildNoTransform(0); 266 } 267 /** 268 * @attribute syn 269 * @aspect Annotations 270 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Annotations.jrag:57 271 */ 272 public boolean validTarget(Annotation a) { 273 ASTNode$State state = state(); 274 try { 275 for(int i = 0; i < getNumElementValue(); i++) 276 if(getElementValue(i).validTarget(a)) 277 return true; 278 return false; 279 } 280 finally { 281 } 282 } 283 /** 284 * @attribute syn 285 * @aspect Annotations 286 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Annotations.jrag:181 287 */ 288 public ElementValue definesElementTypeValue(String name) { 289 ASTNode$State state = state(); 290 try { 291 for(int i = 0; i < getNumElementValue(); i++) 292 if(getElementValue(i).definesElementTypeValue(name) != null) 293 return getElementValue(i).definesElementTypeValue(name); 294 return null; 295 } 296 finally { 297 } 298 } 299 /** 300 * @attribute syn 301 * @aspect Annotations 302 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Annotations.jrag:295 303 */ 304 public boolean hasValue(String s) { 305 ASTNode$State state = state(); 306 try { 307 for(int i = 0; i < getNumElementValue(); i++) 308 if(getElementValue(i).hasValue(s)) 309 return true; 310 return false; 311 } 312 finally { 313 } 314 } 315 /** 316 * @attribute syn 317 * @aspect Annotations 318 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Annotations.jrag:495 319 */ 320 public boolean commensurateWithArrayDecl(ArrayDecl type) { 321 ASTNode$State state = state(); 322 try { 323 for(int i = 0; i < getNumElementValue(); i++) 324 if(!type.componentType().commensurateWith(getElementValue(i))) 325 return false; 326 return true; 327 } 328 finally { 329 } 330 } 331 /** 332 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Annotations.jrag:178 333 * @apilevel internal 334 */ 335 public ElementValue Define_ElementValue_lookupElementTypeValue(ASTNode caller, ASTNode child, String name) { 336 if(caller == getElementValueListNoTransform()) { 337 int childIndex = caller.getIndexOfChild(child); 338 return definesElementTypeValue(name); 339 } 340 else { return getParent().Define_ElementValue_lookupElementTypeValue(this, caller, name); 341 } 342 } 343 /** 344 * @apilevel internal 345 */ 346 public ASTNode rewriteTo() { 347 return super.rewriteTo(); 348 } 349 }