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 SuperConstructorAccess : {@link ConstructorAccess}; 015 * @ast node 016 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/java.ast:22 017 */ 018 public class SuperConstructorAccess extends ConstructorAccess 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 SuperConstructorAccess clone() throws CloneNotSupportedException { 034 SuperConstructorAccess node = (SuperConstructorAccess)super.clone(); 035 node.decls_computed = false; 036 node.decls_value = null; 037 node.in$Circle(false); 038 node.is$Final(false); 039 return node; 040 } 041 /** 042 * @apilevel internal 043 */ 044 @SuppressWarnings({"unchecked", "cast"}) 045 public SuperConstructorAccess copy() { 046 047 try { 048 SuperConstructorAccess node = (SuperConstructorAccess) clone(); 049 node.parent = null; 050 if(children != null) 051 node.children = (ASTNode[]) children.clone(); 052 053 return node; 054 } catch (CloneNotSupportedException e) { 055 throw new Error("Error: clone not supported for " + getClass().getName()); 056 } 057 058 }/** 059 * Create a deep copy of the AST subtree at this node. 060 * The copy is dangling, i.e. has no parent. 061 * @return dangling copy of the subtree at this node 062 * @apilevel low-level 063 */ 064 @SuppressWarnings({"unchecked", "cast"}) 065 public SuperConstructorAccess fullCopy() { 066 067 SuperConstructorAccess tree = (SuperConstructorAccess) copy(); 068 if (children != null) { 069 for (int i = 0; i < children.length; ++i) { 070 071 ASTNode child = (ASTNode) children[i]; 072 if(child != null) { 073 child = child.fullCopy(); 074 tree.setChild(child, i); 075 } 076 } 077 } 078 return tree; 079 080 } /** 081 * @ast method 082 * @aspect TypeHierarchyCheck 083 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeHierarchyCheck.jrag:63 084 */ 085 public void nameCheck() { 086 super.nameCheck(); 087 // 8.8.5.1 088 TypeDecl c = hostType(); 089 TypeDecl s = c.isClassDecl() && ((ClassDecl)c).hasSuperclass() ? ((ClassDecl)c).superclass() : unknownType(); 090 if(isQualified()) { 091 if(!s.isInnerType() || s.inStaticContext()) 092 error("the super type " + s.typeName() + " of " + c.typeName() + 093 " is not an inner class"); 094 095 else if(!qualifier().type().instanceOf(s.enclosingType())) 096 error("The type of this primary expression, " + 097 qualifier().type().typeName() + " is not enclosing the super type, " + 098 s.typeName() + ", of " + c.typeName()); 099 } 100 if(!isQualified() && s.isInnerType()) { 101 if(!c.isInnerType()) { 102 error("no enclosing instance for " + s.typeName() + " when accessed in " + this); 103 } 104 } 105 if(s.isInnerType() && hostType().instanceOf(s.enclosingType())) 106 error("cannot reference this before supertype constructor has been called"); 107 } 108 /** 109 * @ast method 110 * @aspect CreateBCode 111 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CreateBCode.jrag:627 112 */ 113 public void createBCode(CodeGeneration gen) { 114 ConstructorDecl c = decl(); 115 116 // this 117 gen.emit(Bytecode.ALOAD_0); 118 119 if(c.needsEnclosing()) { 120 if(hasPrevExpr() && !prevExpr().isTypeAccess()) { 121 prevExpr().createBCode(gen); 122 gen.emitDup(); 123 int index = gen.constantPool().addMethodref("java/lang/Object", "getClass", "()Ljava/lang/Class;"); 124 gen.emit(Bytecode.INVOKEVIRTUAL, 0).add2(index); 125 gen.emitPop(); 126 } 127 else { 128 if(hostType().needsSuperEnclosing()) { 129 if(hostType().needsEnclosing()) 130 gen.emit(Bytecode.ALOAD_2); 131 else 132 gen.emit(Bytecode.ALOAD_1); 133 } 134 else { 135 emitThis(gen, superConstructorQualifier(c.hostType().enclosingType())); 136 } 137 } 138 } 139 140 // args 141 for (int i = 0; i < getNumArg(); ++i) { 142 getArg(i).createBCode(gen); 143 getArg(i).type().emitCastTo(gen, decl().getParameter(i).type()); // MethodInvocationConversion 144 } 145 if(decl().isPrivate() && decl().hostType() != hostType()) { 146 gen.emit(Bytecode.ACONST_NULL); 147 decl().createAccessor().emitInvokeConstructor(gen); 148 } 149 else { 150 decl().emitInvokeConstructor(gen); 151 } 152 } 153 /** 154 * @ast method 155 * @aspect Transformations 156 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/Transformations.jrag:149 157 */ 158 public void transformation() { 159 // this$val 160 addEnclosingVariables(); 161 // touch accessorIndex to force creation of private constructorAccessor 162 if(decl().isPrivate() && decl().hostType() != hostType()) { 163 decl().createAccessor(); 164 } 165 super.transformation(); 166 } 167 /** 168 * @ast method 169 * 170 */ 171 public SuperConstructorAccess() { 172 super(); 173 174 175 } 176 /** 177 * Initializes the child array to the correct size. 178 * Initializes List and Opt nta children. 179 * @apilevel internal 180 * @ast method 181 * @ast method 182 * 183 */ 184 public void init$Children() { 185 children = new ASTNode[1]; 186 setChild(new List(), 0); 187 } 188 /** 189 * @ast method 190 * 191 */ 192 public SuperConstructorAccess(String p0, List<Expr> p1) { 193 setID(p0); 194 setChild(p1, 0); 195 } 196 /** 197 * @ast method 198 * 199 */ 200 public SuperConstructorAccess(beaver.Symbol p0, List<Expr> p1) { 201 setID(p0); 202 setChild(p1, 0); 203 } 204 /** 205 * @apilevel low-level 206 * @ast method 207 * 208 */ 209 protected int numChildren() { 210 return 1; 211 } 212 /** 213 * @apilevel internal 214 * @ast method 215 * 216 */ 217 public boolean mayHaveRewrite() { 218 return false; 219 } 220 /** 221 * Replaces the lexeme ID. 222 * @param value The new value for the lexeme ID. 223 * @apilevel high-level 224 * @ast method 225 * 226 */ 227 public void setID(String value) { 228 tokenString_ID = value; 229 } 230 /** 231 * JastAdd-internal setter for lexeme ID using the Beaver parser. 232 * @apilevel internal 233 * @ast method 234 * 235 */ 236 public void setID(beaver.Symbol symbol) { 237 if(symbol.value != null && !(symbol.value instanceof String)) 238 throw new UnsupportedOperationException("setID is only valid for String lexemes"); 239 tokenString_ID = (String)symbol.value; 240 IDstart = symbol.getStart(); 241 IDend = symbol.getEnd(); 242 } 243 /** 244 * Retrieves the value for the lexeme ID. 245 * @return The value for the lexeme ID. 246 * @apilevel high-level 247 * @ast method 248 * 249 */ 250 public String getID() { 251 return tokenString_ID != null ? tokenString_ID : ""; 252 } 253 /** 254 * Replaces the Arg list. 255 * @param list The new list node to be used as the Arg list. 256 * @apilevel high-level 257 * @ast method 258 * 259 */ 260 public void setArgList(List<Expr> list) { 261 setChild(list, 0); 262 } 263 /** 264 * Retrieves the number of children in the Arg list. 265 * @return Number of children in the Arg list. 266 * @apilevel high-level 267 * @ast method 268 * 269 */ 270 public int getNumArg() { 271 return getArgList().getNumChild(); 272 } 273 /** 274 * Retrieves the number of children in the Arg list. 275 * Calling this method will not trigger rewrites.. 276 * @return Number of children in the Arg list. 277 * @apilevel low-level 278 * @ast method 279 * 280 */ 281 public int getNumArgNoTransform() { 282 return getArgListNoTransform().getNumChildNoTransform(); 283 } 284 /** 285 * Retrieves the element at index {@code i} in the Arg list.. 286 * @param i Index of the element to return. 287 * @return The element at position {@code i} in the Arg list. 288 * @apilevel high-level 289 * @ast method 290 * 291 */ 292 @SuppressWarnings({"unchecked", "cast"}) 293 public Expr getArg(int i) { 294 return (Expr)getArgList().getChild(i); 295 } 296 /** 297 * Append an element to the Arg list. 298 * @param node The element to append to the Arg list. 299 * @apilevel high-level 300 * @ast method 301 * 302 */ 303 public void addArg(Expr node) { 304 List<Expr> list = (parent == null || state == null) ? getArgListNoTransform() : getArgList(); 305 list.addChild(node); 306 } 307 /** 308 * @apilevel low-level 309 * @ast method 310 * 311 */ 312 public void addArgNoTransform(Expr node) { 313 List<Expr> list = getArgListNoTransform(); 314 list.addChild(node); 315 } 316 /** 317 * Replaces the Arg list element at index {@code i} with the new node {@code node}. 318 * @param node The new node to replace the old list element. 319 * @param i The list index of the node to be replaced. 320 * @apilevel high-level 321 * @ast method 322 * 323 */ 324 public void setArg(Expr node, int i) { 325 List<Expr> list = getArgList(); 326 list.setChild(node, i); 327 } 328 /** 329 * Retrieves the Arg list. 330 * @return The node representing the Arg list. 331 * @apilevel high-level 332 * @ast method 333 * 334 */ 335 public List<Expr> getArgs() { 336 return getArgList(); 337 } 338 /** 339 * Retrieves the Arg list. 340 * <p><em>This method does not invoke AST transformations.</em></p> 341 * @return The node representing the Arg list. 342 * @apilevel low-level 343 * @ast method 344 * 345 */ 346 public List<Expr> getArgsNoTransform() { 347 return getArgListNoTransform(); 348 } 349 /** 350 * Retrieves the Arg list. 351 * @return The node representing the Arg list. 352 * @apilevel high-level 353 * @ast method 354 * 355 */ 356 @SuppressWarnings({"unchecked", "cast"}) 357 public List<Expr> getArgList() { 358 List<Expr> list = (List<Expr>)getChild(0); 359 list.getNumChild(); 360 return list; 361 } 362 /** 363 * Retrieves the Arg list. 364 * <p><em>This method does not invoke AST transformations.</em></p> 365 * @return The node representing the Arg list. 366 * @apilevel low-level 367 * @ast method 368 * 369 */ 370 @SuppressWarnings({"unchecked", "cast"}) 371 public List<Expr> getArgListNoTransform() { 372 return (List<Expr>)getChildNoTransform(0); 373 } 374 /** 375 * @attribute syn 376 * @aspect DA 377 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:235 378 */ 379 public boolean isDAafter(Variable v) { 380 ASTNode$State state = state(); 381 try { return isDAbefore(v); } 382 finally { 383 } 384 } 385 /** 386 * @attribute syn 387 * @aspect DU 388 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:694 389 */ 390 public boolean isDUafter(Variable v) { 391 ASTNode$State state = state(); 392 try { return isDUbefore(v); } 393 finally { 394 } 395 } 396 /** 397 * @apilevel internal 398 */ 399 protected boolean decls_computed = false; 400 /** 401 * @apilevel internal 402 */ 403 protected SimpleSet decls_value; 404 /** 405 * @attribute syn 406 * @aspect MethodSignature15 407 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/MethodSignature.jrag:77 408 */ 409 @SuppressWarnings({"unchecked", "cast"}) 410 public SimpleSet decls() { 411 if(decls_computed) { 412 return decls_value; 413 } 414 ASTNode$State state = state(); 415 int num = state.boundariesCrossed; 416 boolean isFinal = this.is$Final(); 417 decls_value = decls_compute(); 418 if(isFinal && num == state().boundariesCrossed){ decls_computed = true; } 419 return decls_value; 420 } 421 /** 422 * @apilevel internal 423 */ 424 private SimpleSet decls_compute() { 425 Collection c = hasPrevExpr() && !prevExpr().isTypeAccess() ? 426 hostType().lookupSuperConstructor() : lookupSuperConstructor(); 427 return chooseConstructor(c, getArgList()); 428 } 429 /** 430 * @attribute syn 431 * @aspect Names 432 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/QualifiedNames.jrag:20 433 */ 434 public String name() { 435 ASTNode$State state = state(); 436 try { return "super"; } 437 finally { 438 } 439 } 440 /** 441 * @attribute syn 442 * @aspect AccessTypes 443 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ResolveAmbiguousNames.jrag:49 444 */ 445 public boolean isSuperConstructorAccess() { 446 ASTNode$State state = state(); 447 try { return true; } 448 finally { 449 } 450 } 451 /** 452 * @attribute syn 453 * @aspect SyntacticClassification 454 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/SyntacticClassification.jrag:56 455 */ 456 public NameType predNameType() { 457 ASTNode$State state = state(); 458 try { return NameType.EXPRESSION_NAME; } 459 finally { 460 } 461 } 462 /** 463 * @attribute inh 464 * @aspect ConstructScope 465 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupConstructor.jrag:19 466 */ 467 @SuppressWarnings({"unchecked", "cast"}) 468 public Collection lookupSuperConstructor() { 469 ASTNode$State state = state(); 470 Collection lookupSuperConstructor_value = getParent().Define_Collection_lookupSuperConstructor(this, null); 471 return lookupSuperConstructor_value; 472 } 473 /** 474 * @attribute inh 475 * @aspect TypeCheck 476 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeCheck.jrag:503 477 */ 478 @SuppressWarnings({"unchecked", "cast"}) 479 public TypeDecl enclosingInstance() { 480 ASTNode$State state = state(); 481 TypeDecl enclosingInstance_value = getParent().Define_TypeDecl_enclosingInstance(this, null); 482 return enclosingInstance_value; 483 } 484 /** 485 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupType.jrag:89 486 * @apilevel internal 487 */ 488 public boolean Define_boolean_hasPackage(ASTNode caller, ASTNode child, String packageName) { 489 if(caller == getArgListNoTransform()) { 490 int childIndex = caller.getIndexOfChild(child); 491 return unqualifiedScope().hasPackage(packageName); 492 } 493 else { return super.Define_boolean_hasPackage(caller, child, packageName); 494 } 495 } 496 /** 497 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupVariable.jrag:134 498 * @apilevel internal 499 */ 500 public SimpleSet Define_SimpleSet_lookupVariable(ASTNode caller, ASTNode child, String name) { 501 if(caller == getArgListNoTransform()) { 502 int childIndex = caller.getIndexOfChild(child); 503 return unqualifiedScope().lookupVariable(name); 504 } 505 else { return super.Define_SimpleSet_lookupVariable(caller, child, name); 506 } 507 } 508 /** 509 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeHierarchyCheck.jrag:131 510 * @apilevel internal 511 */ 512 public boolean Define_boolean_inExplicitConstructorInvocation(ASTNode caller, ASTNode child) { 513 if(caller == getArgListNoTransform()) { 514 int childIndex = caller.getIndexOfChild(child); 515 return true; 516 } 517 else { return super.Define_boolean_inExplicitConstructorInvocation(caller, child); 518 } 519 } 520 /** 521 * @apilevel internal 522 */ 523 public ASTNode rewriteTo() { 524 return super.rewriteTo(); 525 } 526 }