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/java4/grammar/Java.ast:131 027 * @production Dims : {@link ASTNode} ::= <span class="component">[{@link Expr}]</span>; 028 029 */ 030 public class Dims extends ASTNode<ASTNode> implements Cloneable { 031 /** 032 * @aspect Java4PrettyPrint 033 * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrint.jadd:250 034 */ 035 public void prettyPrint(PrettyPrinter out) { 036 out.print("["); 037 out.print(getExprOpt()); 038 out.print("]"); 039 } 040 /** 041 * @declaredat ASTNode:1 042 */ 043 public Dims() { 044 super(); 045 } 046 /** 047 * Initializes the child array to the correct size. 048 * Initializes List and Opt nta children. 049 * @apilevel internal 050 * @ast method 051 * @declaredat ASTNode:10 052 */ 053 public void init$Children() { 054 children = new ASTNode[1]; 055 setChild(new Opt(), 0); 056 } 057 /** 058 * @declaredat ASTNode:14 059 */ 060 public Dims(Opt<Expr> p0) { 061 setChild(p0, 0); 062 } 063 /** 064 * @apilevel low-level 065 * @declaredat ASTNode:20 066 */ 067 protected int numChildren() { 068 return 1; 069 } 070 /** 071 * @apilevel internal 072 * @declaredat ASTNode:26 073 */ 074 public boolean mayHaveRewrite() { 075 return false; 076 } 077 /** 078 * @apilevel internal 079 * @declaredat ASTNode:32 080 */ 081 public void flushAttrCache() { 082 super.flushAttrCache(); 083 } 084 /** 085 * @apilevel internal 086 * @declaredat ASTNode:38 087 */ 088 public void flushCollectionCache() { 089 super.flushCollectionCache(); 090 } 091 /** 092 * @apilevel internal 093 * @declaredat ASTNode:44 094 */ 095 public void flushRewriteCache() { 096 super.flushRewriteCache(); 097 } 098 /** 099 * @apilevel internal 100 * @declaredat ASTNode:50 101 */ 102 public Dims clone() throws CloneNotSupportedException { 103 Dims node = (Dims) super.clone(); 104 return node; 105 } 106 /** 107 * @apilevel internal 108 * @declaredat ASTNode:57 109 */ 110 public Dims copy() { 111 try { 112 Dims node = (Dims) clone(); 113 node.parent = null; 114 if (children != null) { 115 node.children = (ASTNode[]) children.clone(); 116 } 117 return node; 118 } catch (CloneNotSupportedException e) { 119 throw new Error("Error: clone not supported for " + getClass().getName()); 120 } 121 } 122 /** 123 * Create a deep copy of the AST subtree at this node. 124 * The copy is dangling, i.e. has no parent. 125 * @return dangling copy of the subtree at this node 126 * @apilevel low-level 127 * @deprecated Please use treeCopy or treeCopyNoTransform instead 128 * @declaredat ASTNode:76 129 */ 130 @Deprecated 131 public Dims fullCopy() { 132 return treeCopyNoTransform(); 133 } 134 /** 135 * Create a deep copy of the AST subtree at this node. 136 * The copy is dangling, i.e. has no parent. 137 * @return dangling copy of the subtree at this node 138 * @apilevel low-level 139 * @declaredat ASTNode:86 140 */ 141 public Dims treeCopyNoTransform() { 142 Dims tree = (Dims) copy(); 143 if (children != null) { 144 for (int i = 0; i < children.length; ++i) { 145 ASTNode child = (ASTNode) children[i]; 146 if (child != null) { 147 child = child.treeCopyNoTransform(); 148 tree.setChild(child, i); 149 } 150 } 151 } 152 return tree; 153 } 154 /** 155 * Create a deep copy of the AST subtree at this node. 156 * The subtree of this node is traversed to trigger rewrites before copy. 157 * The copy is dangling, i.e. has no parent. 158 * @return dangling copy of the subtree at this node 159 * @apilevel low-level 160 * @declaredat ASTNode:106 161 */ 162 public Dims treeCopy() { 163 doFullTraversal(); 164 return treeCopyNoTransform(); 165 } 166 /** 167 * @apilevel internal 168 * @declaredat ASTNode:113 169 */ 170 protected boolean is$Equal(ASTNode node) { 171 return super.is$Equal(node); 172 } 173 /** 174 * Replaces the optional node for the Expr child. This is the <code>Opt</code> 175 * node containing the child Expr, not the actual child! 176 * @param opt The new node to be used as the optional node for the Expr child. 177 * @apilevel low-level 178 */ 179 public void setExprOpt(Opt<Expr> opt) { 180 setChild(opt, 0); 181 } 182 /** 183 * Replaces the (optional) Expr child. 184 * @param node The new node to be used as the Expr child. 185 * @apilevel high-level 186 */ 187 public void setExpr(Expr node) { 188 getExprOpt().setChild(node, 0); 189 } 190 /** 191 * Check whether the optional Expr child exists. 192 * @return {@code true} if the optional Expr child exists, {@code false} if it does not. 193 * @apilevel high-level 194 */ 195 public boolean hasExpr() { 196 return getExprOpt().getNumChild() != 0; 197 } 198 /** 199 * Retrieves the (optional) Expr child. 200 * @return The Expr child, if it exists. Returns {@code null} otherwise. 201 * @apilevel low-level 202 */ 203 public Expr getExpr() { 204 return (Expr) getExprOpt().getChild(0); 205 } 206 /** 207 * Retrieves the optional node for the Expr child. This is the <code>Opt</code> node containing the child Expr, not the actual child! 208 * @return The optional node for child the Expr child. 209 * @apilevel low-level 210 */ 211 @ASTNodeAnnotation.OptChild(name="Expr") 212 public Opt<Expr> getExprOpt() { 213 return (Opt<Expr>) getChild(0); 214 } 215 /** 216 * Retrieves the optional node for child Expr. This is the <code>Opt</code> node containing the child Expr, not the actual child! 217 * <p><em>This method does not invoke AST transformations.</em></p> 218 * @return The optional node for child Expr. 219 * @apilevel low-level 220 */ 221 public Opt<Expr> getExprOptNoTransform() { 222 return (Opt<Expr>) getChildNoTransform(0); 223 } 224 /** 225 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:196 226 * @apilevel internal 227 */ 228 public boolean Define_assignmentContext(ASTNode caller, ASTNode child) { 229 if (caller == getExprOptNoTransform()) { 230 // @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:379 231 return false; 232 } 233 else { 234 return getParent().Define_assignmentContext(this, caller); 235 } 236 } 237 protected boolean canDefine_assignmentContext(ASTNode caller, ASTNode child) { 238 return true; 239 } 240 /** 241 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:197 242 * @apilevel internal 243 */ 244 public boolean Define_invocationContext(ASTNode caller, ASTNode child) { 245 if (caller == getExprOptNoTransform()) { 246 // @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:380 247 return false; 248 } 249 else { 250 return getParent().Define_invocationContext(this, caller); 251 } 252 } 253 protected boolean canDefine_invocationContext(ASTNode caller, ASTNode child) { 254 return true; 255 } 256 /** 257 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:198 258 * @apilevel internal 259 */ 260 public boolean Define_castContext(ASTNode caller, ASTNode child) { 261 if (caller == getExprOptNoTransform()) { 262 // @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:381 263 return false; 264 } 265 else { 266 return getParent().Define_castContext(this, caller); 267 } 268 } 269 protected boolean canDefine_castContext(ASTNode caller, ASTNode child) { 270 return true; 271 } 272 /** 273 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:199 274 * @apilevel internal 275 */ 276 public boolean Define_stringContext(ASTNode caller, ASTNode child) { 277 if (caller == getExprOptNoTransform()) { 278 // @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:382 279 return false; 280 } 281 else { 282 return getParent().Define_stringContext(this, caller); 283 } 284 } 285 protected boolean canDefine_stringContext(ASTNode caller, ASTNode child) { 286 return true; 287 } 288 /** 289 * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:200 290 * @apilevel internal 291 */ 292 public boolean Define_numericContext(ASTNode caller, ASTNode child) { 293 if (caller == getExprOptNoTransform()) { 294 // @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:383 295 return false; 296 } 297 else { 298 return getParent().Define_numericContext(this, caller); 299 } 300 } 301 protected boolean canDefine_numericContext(ASTNode caller, ASTNode child) { 302 return true; 303 } 304 /** 305 * @apilevel internal 306 */ 307 public ASTNode rewriteTo() { 308 return super.rewriteTo(); 309 } 310 }