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