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:71 027 * @production StaticInitializer : {@link BodyDecl} ::= <span class="component">{@link Block}</span>; 028 029 */ 030 public class StaticInitializer extends BodyDecl implements Cloneable { 031 /** 032 * @aspect Modifiers 033 * @declaredat /home/jesper/git/extendj/java4/frontend/Modifiers.jrag:217 034 */ 035 public void checkModifiers() { 036 super.checkModifiers(); 037 if (hostType().isInnerClass()) { 038 error("*** Inner classes may not declare static initializers"); 039 } 040 } 041 /** 042 * @aspect Java4PrettyPrint 043 * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrint.jadd:244 044 */ 045 public void prettyPrint(PrettyPrinter out) { 046 out.print("static "); 047 if (!blockIsEmpty()) { 048 out.print(getBlock()); 049 } 050 } 051 /** 052 * @aspect UnreachableStatements 053 * @declaredat /home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:40 054 */ 055 void checkUnreachableStmt() { 056 if (!getBlock().canCompleteNormally()) { 057 errorf("static initializer in %s can not complete normally", hostType().fullName()); 058 } 059 } 060 /** 061 * @declaredat ASTNode:1 062 */ 063 public StaticInitializer() { 064 super(); 065 } 066 /** 067 * Initializes the child array to the correct size. 068 * Initializes List and Opt nta children. 069 * @apilevel internal 070 * @ast method 071 * @declaredat ASTNode:10 072 */ 073 public void init$Children() { 074 children = new ASTNode[1]; 075 } 076 /** 077 * @declaredat ASTNode:13 078 */ 079 public StaticInitializer(Block p0) { 080 setChild(p0, 0); 081 } 082 /** 083 * @apilevel low-level 084 * @declaredat ASTNode:19 085 */ 086 protected int numChildren() { 087 return 1; 088 } 089 /** 090 * @apilevel internal 091 * @declaredat ASTNode:25 092 */ 093 public boolean mayHaveRewrite() { 094 return false; 095 } 096 /** 097 * @apilevel internal 098 * @declaredat ASTNode:31 099 */ 100 public void flushAttrCache() { 101 super.flushAttrCache(); 102 isDAafter_Variable_reset(); 103 isDUafter_Variable_reset(); 104 handlesException_TypeDecl_reset(); 105 } 106 /** 107 * @apilevel internal 108 * @declaredat ASTNode:40 109 */ 110 public void flushCollectionCache() { 111 super.flushCollectionCache(); 112 } 113 /** 114 * @apilevel internal 115 * @declaredat ASTNode:46 116 */ 117 public void flushRewriteCache() { 118 super.flushRewriteCache(); 119 } 120 /** 121 * @apilevel internal 122 * @declaredat ASTNode:52 123 */ 124 public StaticInitializer clone() throws CloneNotSupportedException { 125 StaticInitializer node = (StaticInitializer) super.clone(); 126 return node; 127 } 128 /** 129 * @apilevel internal 130 * @declaredat ASTNode:59 131 */ 132 public StaticInitializer copy() { 133 try { 134 StaticInitializer node = (StaticInitializer) clone(); 135 node.parent = null; 136 if (children != null) { 137 node.children = (ASTNode[]) children.clone(); 138 } 139 return node; 140 } catch (CloneNotSupportedException e) { 141 throw new Error("Error: clone not supported for " + getClass().getName()); 142 } 143 } 144 /** 145 * Create a deep copy of the AST subtree at this node. 146 * The copy is dangling, i.e. has no parent. 147 * @return dangling copy of the subtree at this node 148 * @apilevel low-level 149 * @deprecated Please use treeCopy or treeCopyNoTransform instead 150 * @declaredat ASTNode:78 151 */ 152 @Deprecated 153 public StaticInitializer fullCopy() { 154 return treeCopyNoTransform(); 155 } 156 /** 157 * Create a deep copy of the AST subtree at this node. 158 * The copy is dangling, i.e. has no parent. 159 * @return dangling copy of the subtree at this node 160 * @apilevel low-level 161 * @declaredat ASTNode:88 162 */ 163 public StaticInitializer treeCopyNoTransform() { 164 StaticInitializer tree = (StaticInitializer) copy(); 165 if (children != null) { 166 for (int i = 0; i < children.length; ++i) { 167 ASTNode child = (ASTNode) children[i]; 168 if (child != null) { 169 child = child.treeCopyNoTransform(); 170 tree.setChild(child, i); 171 } 172 } 173 } 174 return tree; 175 } 176 /** 177 * Create a deep copy of the AST subtree at this node. 178 * The subtree of this node is traversed to trigger rewrites before copy. 179 * The copy is dangling, i.e. has no parent. 180 * @return dangling copy of the subtree at this node 181 * @apilevel low-level 182 * @declaredat ASTNode:108 183 */ 184 public StaticInitializer treeCopy() { 185 doFullTraversal(); 186 return treeCopyNoTransform(); 187 } 188 /** 189 * @apilevel internal 190 * @declaredat ASTNode:115 191 */ 192 protected boolean is$Equal(ASTNode node) { 193 return super.is$Equal(node); 194 } 195 /** 196 * Replaces the Block child. 197 * @param node The new node to replace the Block child. 198 * @apilevel high-level 199 */ 200 public void setBlock(Block node) { 201 setChild(node, 0); 202 } 203 /** 204 * Retrieves the Block child. 205 * @return The current node used as the Block child. 206 * @apilevel high-level 207 */ 208 @ASTNodeAnnotation.Child(name="Block") 209 public Block getBlock() { 210 return (Block) getChild(0); 211 } 212 /** 213 * Retrieves the Block child. 214 * <p><em>This method does not invoke AST transformations.</em></p> 215 * @return The current node used as the Block child. 216 * @apilevel low-level 217 */ 218 public Block getBlockNoTransform() { 219 return (Block) getChildNoTransform(0); 220 } 221 /** 222 * @apilevel internal 223 */ 224 protected java.util.Map isDAafter_Variable_values; 225 /** 226 * @apilevel internal 227 */ 228 private void isDAafter_Variable_reset() { 229 isDAafter_Variable_values = null; 230 } 231 /** 232 * @attribute syn 233 * @aspect DA 234 * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:266 235 */ 236 @ASTNodeAnnotation.Attribute 237 public boolean isDAafter(Variable v) { 238 Object _parameters = v; 239 if (isDAafter_Variable_values == null) isDAafter_Variable_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 240 ASTNode$State state = state(); 241 if (isDAafter_Variable_values.containsKey(_parameters)) { 242 return (Boolean) isDAafter_Variable_values.get(_parameters); 243 } 244 boolean intermediate = state.INTERMEDIATE_VALUE; 245 state.INTERMEDIATE_VALUE = false; 246 int num = state.boundariesCrossed; 247 boolean isFinal = this.is$Final(); 248 boolean isDAafter_Variable_value = getBlock().isDAafter(v); 249 if (isFinal && num == state().boundariesCrossed) { 250 isDAafter_Variable_values.put(_parameters, isDAafter_Variable_value); 251 } else { 252 } 253 state.INTERMEDIATE_VALUE |= intermediate; 254 255 return isDAafter_Variable_value; 256 } 257 /** 258 * @apilevel internal 259 */ 260 protected java.util.Map isDUafter_Variable_values; 261 /** 262 * @apilevel internal 263 */ 264 private void isDUafter_Variable_reset() { 265 isDUafter_Variable_values = null; 266 } 267 /** 268 * @attribute syn 269 * @aspect DU 270 * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:796 271 */ 272 @ASTNodeAnnotation.Attribute 273 public boolean isDUafter(Variable v) { 274 Object _parameters = v; 275 if (isDUafter_Variable_values == null) isDUafter_Variable_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 276 ASTNode$State state = state(); 277 if (isDUafter_Variable_values.containsKey(_parameters)) { 278 return (Boolean) isDUafter_Variable_values.get(_parameters); 279 } 280 boolean intermediate = state.INTERMEDIATE_VALUE; 281 state.INTERMEDIATE_VALUE = false; 282 int num = state.boundariesCrossed; 283 boolean isFinal = this.is$Final(); 284 boolean isDUafter_Variable_value = getBlock().isDUafter(v); 285 if (isFinal && num == state().boundariesCrossed) { 286 isDUafter_Variable_values.put(_parameters, isDUafter_Variable_value); 287 } else { 288 } 289 state.INTERMEDIATE_VALUE |= intermediate; 290 291 return isDUafter_Variable_value; 292 } 293 /** 294 * @attribute syn 295 * @aspect PrettyPrintUtil 296 * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:217 297 */ 298 @ASTNodeAnnotation.Attribute 299 public boolean blockIsEmpty() { 300 boolean blockIsEmpty_value = getBlock().getNumStmt() == 0; 301 302 return blockIsEmpty_value; 303 } 304 /** 305 * @attribute syn 306 * @aspect GenericsParTypeDecl 307 * @declaredat /home/jesper/git/extendj/java5/frontend/GenericsParTypeDecl.jrag:90 308 */ 309 @ASTNodeAnnotation.Attribute 310 public boolean visibleTypeParameters() { 311 boolean visibleTypeParameters_value = false; 312 313 return visibleTypeParameters_value; 314 } 315 /** 316 * @attribute syn 317 * @aspect PreciseRethrow 318 * @declaredat /home/jesper/git/extendj/java8/frontend/EffectivelyFinal.jrag:40 319 */ 320 @ASTNodeAnnotation.Attribute 321 public boolean modifiedInScope(Variable var) { 322 boolean modifiedInScope_Variable_value = getBlock().modifiedInScope(var); 323 324 return modifiedInScope_Variable_value; 325 } 326 /** 327 * @attribute inh 328 * @aspect ExceptionHandling 329 * @declaredat /home/jesper/git/extendj/java4/frontend/ExceptionHandling.jrag:80 330 */ 331 /** 332 * @attribute inh 333 * @aspect ExceptionHandling 334 * @declaredat /home/jesper/git/extendj/java4/frontend/ExceptionHandling.jrag:80 335 */ 336 @ASTNodeAnnotation.Attribute 337 public boolean handlesException(TypeDecl exceptionType) { 338 Object _parameters = exceptionType; 339 if (handlesException_TypeDecl_values == null) handlesException_TypeDecl_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 340 ASTNode$State state = state(); 341 if (handlesException_TypeDecl_values.containsKey(_parameters)) { 342 return (Boolean) handlesException_TypeDecl_values.get(_parameters); 343 } 344 boolean intermediate = state.INTERMEDIATE_VALUE; 345 state.INTERMEDIATE_VALUE = false; 346 int num = state.boundariesCrossed; 347 boolean isFinal = this.is$Final(); 348 boolean handlesException_TypeDecl_value = getParent().Define_handlesException(this, null, exceptionType); 349 if (isFinal && num == state().boundariesCrossed) { 350 handlesException_TypeDecl_values.put(_parameters, handlesException_TypeDecl_value); 351 } else { 352 } 353 state.INTERMEDIATE_VALUE |= intermediate; 354 355 return handlesException_TypeDecl_value; 356 } 357 /** 358 * @apilevel internal 359 */ 360 protected java.util.Map handlesException_TypeDecl_values; 361 /** 362 * @apilevel internal 363 */ 364 private void handlesException_TypeDecl_reset() { 365 handlesException_TypeDecl_values = null; 366 } 367 /** 368 * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:255 369 * @apilevel internal 370 */ 371 public boolean Define_isDAbefore(ASTNode caller, ASTNode child, Variable v) { 372 if (caller == getBlockNoTransform()) { 373 // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:481 374 return isDAbefore(v); 375 } 376 else { 377 return super.Define_isDAbefore(caller, child, v); 378 } 379 } 380 protected boolean canDefine_isDAbefore(ASTNode caller, ASTNode child, Variable v) { 381 return true; 382 } 383 /** 384 * @declaredat /home/jesper/git/extendj/java7/frontend/TryWithResources.jrag:113 385 * @apilevel internal 386 */ 387 public boolean Define_handlesException(ASTNode caller, ASTNode child, TypeDecl exceptionType) { 388 if (caller == getBlockNoTransform()) { 389 // @declaredat /home/jesper/git/extendj/java4/frontend/ExceptionHandling.jrag:236 390 return hostType().isAnonymous() && handlesException(exceptionType); 391 } 392 else { 393 return getParent().Define_handlesException(this, caller, exceptionType); 394 } 395 } 396 protected boolean canDefine_handlesException(ASTNode caller, ASTNode child, TypeDecl exceptionType) { 397 return true; 398 } 399 /** 400 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeCheck.jrag:586 401 * @apilevel internal 402 */ 403 public TypeDecl Define_enclosingInstance(ASTNode caller, ASTNode child) { 404 if (caller == getBlockNoTransform()) { 405 // @declaredat /home/jesper/git/extendj/java4/frontend/TypeCheck.jrag:588 406 return null; 407 } 408 else { 409 return getParent().Define_enclosingInstance(this, caller); 410 } 411 } 412 protected boolean canDefine_enclosingInstance(ASTNode caller, ASTNode child) { 413 return true; 414 } 415 /** 416 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeHierarchyCheck.jrag:182 417 * @apilevel internal 418 */ 419 public boolean Define_inStaticContext(ASTNode caller, ASTNode child) { 420 if (caller == getBlockNoTransform()) { 421 // @declaredat /home/jesper/git/extendj/java4/frontend/TypeHierarchyCheck.jrag:187 422 return true; 423 } 424 else { 425 return getParent().Define_inStaticContext(this, caller); 426 } 427 } 428 protected boolean canDefine_inStaticContext(ASTNode caller, ASTNode child) { 429 return true; 430 } 431 /** 432 * @declaredat /home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:52 433 * @apilevel internal 434 */ 435 public boolean Define_reachable(ASTNode caller, ASTNode child) { 436 if (caller == getBlockNoTransform()) { 437 // @declaredat /home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:65 438 return true; 439 } 440 else { 441 return getParent().Define_reachable(this, caller); 442 } 443 } 444 protected boolean canDefine_reachable(ASTNode caller, ASTNode child) { 445 return true; 446 } 447 /** 448 * @apilevel internal 449 */ 450 public ASTNode rewriteTo() { 451 return super.rewriteTo(); 452 } 453 }