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:13 027 * @production Access : {@link Expr}; 028 029 */ 030 public abstract class Access extends Expr implements Cloneable { 031 /** 032 * @aspect QualifiedNames 033 * @declaredat /home/jesper/git/extendj/java4/frontend/ResolveAmbiguousNames.jrag:181 034 */ 035 public Access addArrayDims(List list) { 036 Access a = this; 037 for (int i = 0; i < list.getNumChildNoTransform(); i++) { 038 Dims dims = (Dims) list.getChildNoTransform(i); 039 Opt opt = dims.getExprOpt(); 040 if (opt.getNumChildNoTransform() == 1) { 041 a = new ArrayTypeWithSizeAccess(a, (Expr) opt.getChildNoTransform(0)); 042 } else { 043 a = new ArrayTypeAccess(a); 044 } 045 a.setStart(dims.start()); 046 a.setEnd(dims.end()); 047 } 048 return a; 049 } 050 /** 051 * @aspect CreateBCode 052 * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:562 053 */ 054 public void emitLoadLocalInNestedClass(CodeGeneration gen, Variable v) { 055 if (inExplicitConstructorInvocation() && enclosingBodyDecl() instanceof ConstructorDecl) { 056 ConstructorDecl c = (ConstructorDecl) enclosingBodyDecl(); 057 v.type().emitLoadLocal(gen, c.localIndexOfEnclosingVariable(v)); 058 } else { 059 String classname = hostType().constantPoolName(); 060 String desc = v.type().typeDescriptor(); 061 String name = "val$" + v.name(); 062 int index = gen.constantPool().addFieldref(classname, name, desc); 063 gen.emit(Bytecode.ALOAD_0); 064 gen.emit(Bytecode.GETFIELD, v.type().variableSize() - 1).add2(index); 065 } 066 } 067 /** 068 * @aspect CreateBCode 069 * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:667 070 */ 071 public void emitThis(CodeGeneration gen, TypeDecl targetDecl) { 072 if (targetDecl == hostType()) { 073 gen.emit(Bytecode.ALOAD_0); 074 } else { 075 TypeDecl enclosing = hostType(); 076 if (inExplicitConstructorInvocation()) { 077 gen.emit(Bytecode.ALOAD_1); 078 enclosing = enclosing.enclosing(); 079 } else { 080 gen.emit(Bytecode.ALOAD_0); 081 } 082 while (enclosing != targetDecl) { 083 String classname = enclosing.constantPoolName(); 084 enclosing = enclosing.enclosingType(); 085 String desc = enclosing.typeDescriptor(); 086 int index = gen.constantPool().addFieldref(classname, "this$0", desc); 087 gen.emit(Bytecode.GETFIELD, 0).add2(index); 088 } 089 } 090 } 091 /** 092 * @aspect InnerClasses 093 * @declaredat /home/jesper/git/extendj/java4/backend/InnerClasses.jrag:139 094 */ 095 protected TypeDecl superConstructorQualifier(TypeDecl targetEnclosingType) { 096 TypeDecl enclosing = hostType(); 097 while (!enclosing.instanceOf(targetEnclosingType)) { 098 enclosing = enclosing.enclosingType(); 099 } 100 return enclosing; 101 } 102 /** 103 * @aspect FunctionalInterface 104 * @declaredat /home/jesper/git/extendj/java8/frontend/FunctionalInterface.jrag:174 105 */ 106 public boolean sameType(Access a) { 107 if (this instanceof ArrayTypeAccess && a instanceof ArrayTypeAccess) { 108 ArrayTypeAccess at1 = (ArrayTypeAccess) this; 109 ArrayTypeAccess at2 = (ArrayTypeAccess) a; 110 return at1.sameType(at2); 111 } else if (this instanceof AbstractWildcard && a instanceof AbstractWildcard) { 112 AbstractWildcard w1 = (AbstractWildcard) this; 113 AbstractWildcard w2 = (AbstractWildcard) a; 114 return w1.sameType(w2); 115 } else if (this instanceof TypeAccess && a instanceof TypeAccess) { 116 TypeAccess t1 = (TypeAccess) this; 117 TypeAccess t2 = (TypeAccess) a; 118 return t1.sameType(t2); 119 } else if (this instanceof ParTypeAccess && a instanceof ParTypeAccess) { 120 ParTypeAccess pta1 = (ParTypeAccess) this; 121 ParTypeAccess pta2 = (ParTypeAccess) a; 122 return pta1.sameType(pta2); 123 } else { 124 return false; 125 } 126 } 127 /** 128 * @declaredat ASTNode:1 129 */ 130 public Access() { 131 super(); 132 } 133 /** 134 * Initializes the child array to the correct size. 135 * Initializes List and Opt nta children. 136 * @apilevel internal 137 * @ast method 138 * @declaredat ASTNode:10 139 */ 140 public void init$Children() { 141 } 142 /** 143 * @apilevel low-level 144 * @declaredat ASTNode:15 145 */ 146 protected int numChildren() { 147 return 0; 148 } 149 /** 150 * @apilevel internal 151 * @declaredat ASTNode:21 152 */ 153 public boolean mayHaveRewrite() { 154 return false; 155 } 156 /** 157 * @apilevel internal 158 * @declaredat ASTNode:27 159 */ 160 public void flushAttrCache() { 161 super.flushAttrCache(); 162 prevExpr_reset(); 163 hasPrevExpr_reset(); 164 type_reset(); 165 } 166 /** 167 * @apilevel internal 168 * @declaredat ASTNode:36 169 */ 170 public void flushCollectionCache() { 171 super.flushCollectionCache(); 172 } 173 /** 174 * @apilevel internal 175 * @declaredat ASTNode:42 176 */ 177 public void flushRewriteCache() { 178 super.flushRewriteCache(); 179 } 180 /** 181 * @apilevel internal 182 * @declaredat ASTNode:48 183 */ 184 public Access clone() throws CloneNotSupportedException { 185 Access node = (Access) super.clone(); 186 return node; 187 } 188 /** 189 * Create a deep copy of the AST subtree at this node. 190 * The copy is dangling, i.e. has no parent. 191 * @return dangling copy of the subtree at this node 192 * @apilevel low-level 193 * @deprecated Please use treeCopy or treeCopyNoTransform instead 194 * @declaredat ASTNode:59 195 */ 196 @Deprecated 197 public abstract Access fullCopy(); 198 /** 199 * Create a deep copy of the AST subtree at this node. 200 * The copy is dangling, i.e. has no parent. 201 * @return dangling copy of the subtree at this node 202 * @apilevel low-level 203 * @declaredat ASTNode:67 204 */ 205 public abstract Access treeCopyNoTransform(); 206 /** 207 * Create a deep copy of the AST subtree at this node. 208 * The subtree of this node is traversed to trigger rewrites before copy. 209 * The copy is dangling, i.e. has no parent. 210 * @return dangling copy of the subtree at this node 211 * @apilevel low-level 212 * @declaredat ASTNode:75 213 */ 214 public abstract Access treeCopy(); 215 /** 216 * @attribute syn 217 * @aspect LookupMethod 218 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupMethod.jrag:39 219 */ 220 @ASTNodeAnnotation.Attribute 221 public Expr unqualifiedScope() { 222 Expr unqualifiedScope_value = isQualified() ? nestedScope() : this; 223 224 return unqualifiedScope_value; 225 } 226 /** 227 * @attribute syn 228 * @aspect QualifiedNames 229 * @declaredat /home/jesper/git/extendj/java4/frontend/ResolveAmbiguousNames.jrag:80 230 */ 231 @ASTNodeAnnotation.Attribute 232 public boolean isQualified() { 233 boolean isQualified_value = hasPrevExpr(); 234 235 return isQualified_value; 236 } 237 /** 238 * @attribute syn 239 * @aspect QualifiedNames 240 * @declaredat /home/jesper/git/extendj/java4/frontend/ResolveAmbiguousNames.jrag:83 241 */ 242 @ASTNodeAnnotation.Attribute 243 public Expr qualifier() { 244 Expr qualifier_value = prevExpr(); 245 246 return qualifier_value; 247 } 248 /** 249 * @attribute syn 250 * @aspect QualifiedNames 251 * @declaredat /home/jesper/git/extendj/java4/frontend/ResolveAmbiguousNames.jrag:89 252 */ 253 @ASTNodeAnnotation.Attribute 254 public Access lastAccess() { 255 Access lastAccess_value = this; 256 257 return lastAccess_value; 258 } 259 /** 260 * @apilevel internal 261 */ 262 protected boolean prevExpr_computed = false; 263 /** 264 * @apilevel internal 265 */ 266 protected Expr prevExpr_value; 267 /** 268 * @apilevel internal 269 */ 270 private void prevExpr_reset() { 271 prevExpr_computed = false; 272 prevExpr_value = null; 273 } 274 /** 275 * @attribute syn 276 * @aspect QualifiedNames 277 * @declaredat /home/jesper/git/extendj/java4/frontend/ResolveAmbiguousNames.jrag:102 278 */ 279 @ASTNodeAnnotation.Attribute 280 public Expr prevExpr() { 281 ASTNode$State state = state(); 282 if (prevExpr_computed) { 283 return prevExpr_value; 284 } 285 boolean intermediate = state.INTERMEDIATE_VALUE; 286 state.INTERMEDIATE_VALUE = false; 287 int num = state.boundariesCrossed; 288 boolean isFinal = this.is$Final(); 289 prevExpr_value = prevExpr_compute(); 290 if (isFinal && num == state().boundariesCrossed) { 291 prevExpr_computed = true; 292 } else { 293 } 294 state.INTERMEDIATE_VALUE |= intermediate; 295 296 return prevExpr_value; 297 } 298 /** 299 * @apilevel internal 300 */ 301 private Expr prevExpr_compute() { 302 if (isLeftChildOfDot()) { 303 if (parentDot().isRightChildOfDot()) { 304 return parentDot().parentDot().leftSide(); 305 } 306 } else if (isRightChildOfDot()) { 307 return parentDot().leftSide(); 308 } 309 throw new Error(this + " does not have a previous expression"); 310 } 311 /** 312 * @apilevel internal 313 */ 314 protected boolean hasPrevExpr_computed = false; 315 /** 316 * @apilevel internal 317 */ 318 protected boolean hasPrevExpr_value; 319 /** 320 * @apilevel internal 321 */ 322 private void hasPrevExpr_reset() { 323 hasPrevExpr_computed = false; 324 } 325 /** 326 * @attribute syn 327 * @aspect QualifiedNames 328 * @declaredat /home/jesper/git/extendj/java4/frontend/ResolveAmbiguousNames.jrag:114 329 */ 330 @ASTNodeAnnotation.Attribute 331 public boolean hasPrevExpr() { 332 ASTNode$State state = state(); 333 if (hasPrevExpr_computed) { 334 return hasPrevExpr_value; 335 } 336 boolean intermediate = state.INTERMEDIATE_VALUE; 337 state.INTERMEDIATE_VALUE = false; 338 int num = state.boundariesCrossed; 339 boolean isFinal = this.is$Final(); 340 hasPrevExpr_value = hasPrevExpr_compute(); 341 if (isFinal && num == state().boundariesCrossed) { 342 hasPrevExpr_computed = true; 343 } else { 344 } 345 state.INTERMEDIATE_VALUE |= intermediate; 346 347 return hasPrevExpr_value; 348 } 349 /** 350 * @apilevel internal 351 */ 352 private boolean hasPrevExpr_compute() { 353 if (isLeftChildOfDot()) { 354 if (parentDot().isRightChildOfDot()) { 355 return true; 356 } 357 } else if (isRightChildOfDot()) { 358 return true; 359 } 360 return false; 361 } 362 /** 363 * Defines the expected kind of name for the left hand side in a qualified 364 * expression. 365 * @attribute syn 366 * @aspect SyntacticClassification 367 * @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:58 368 */ 369 @ASTNodeAnnotation.Attribute 370 public NameType predNameType() { 371 { 372 switch (nameType()) { 373 case PACKAGE_NAME: 374 return NameType.PACKAGE_NAME; 375 case TYPE_NAME: 376 case PACKAGE_OR_TYPE_NAME: 377 return NameType.PACKAGE_OR_TYPE_NAME; 378 case AMBIGUOUS_NAME: 379 case EXPRESSION_NAME: 380 return NameType.AMBIGUOUS_NAME; 381 case NOT_CLASSIFIED: 382 default: 383 return NameType.NOT_CLASSIFIED; 384 } 385 } 386 } 387 /** 388 * @apilevel internal 389 */ 390 protected boolean type_computed = false; 391 /** 392 * @apilevel internal 393 */ 394 protected TypeDecl type_value; 395 /** 396 * @apilevel internal 397 */ 398 private void type_reset() { 399 type_computed = false; 400 type_value = null; 401 } 402 /** 403 * @attribute syn 404 * @aspect TypeAnalysis 405 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:302 406 */ 407 @ASTNodeAnnotation.Attribute 408 public TypeDecl type() { 409 ASTNode$State state = state(); 410 if (type_computed) { 411 return type_value; 412 } 413 boolean intermediate = state.INTERMEDIATE_VALUE; 414 state.INTERMEDIATE_VALUE = false; 415 int num = state.boundariesCrossed; 416 boolean isFinal = this.is$Final(); 417 type_value = unknownType(); 418 if (isFinal && num == state().boundariesCrossed) { 419 type_computed = true; 420 } else { 421 } 422 state.INTERMEDIATE_VALUE |= intermediate; 423 424 return type_value; 425 } 426 /** 427 * @attribute syn 428 * @aspect CodeGeneration 429 * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:37 430 */ 431 @ASTNodeAnnotation.Attribute 432 public int sourceLineNumber() { 433 int sourceLineNumber_value = findFirstSourceLineNumber(); 434 435 return sourceLineNumber_value; 436 } 437 /** 438 * WARNING: this attribute is not the same as TypeDecl.isWildcard, 439 * which returns true for any wildcard type (even bounded wildcard types). 440 * @return {@code true} if this is an unbounded wildcard access 441 * @attribute syn 442 * @aspect ReifiableTypes 443 * @declaredat /home/jesper/git/extendj/java5/frontend/ReifiableTypes.jrag:106 444 */ 445 @ASTNodeAnnotation.Attribute 446 public boolean isWildcard() { 447 boolean isWildcard_value = false; 448 449 return isWildcard_value; 450 } 451 /** 452 * @attribute syn 453 * @aspect Diamond 454 * @declaredat /home/jesper/git/extendj/java7/frontend/Diamond.jrag:87 455 */ 456 @ASTNodeAnnotation.Attribute 457 public boolean isDiamond() { 458 boolean isDiamond_value = false; 459 460 return isDiamond_value; 461 } 462 /** 463 * Builds a copy of this Access node where all occurrences 464 * of type variables in the original type parameter list have been replaced 465 * by the substitution type parameters. 466 * 467 * @return the substituted Access node 468 * @attribute syn 469 * @aspect Diamond 470 * @declaredat /home/jesper/git/extendj/java7/frontend/Diamond.jrag:361 471 */ 472 @ASTNodeAnnotation.Attribute 473 public Access substituted(Collection<TypeVariable> original, List<TypeVariable> substitution) { 474 Access substituted_Collection_TypeVariable__List_TypeVariable__value = (Access) treeCopyNoTransform(); 475 476 return substituted_Collection_TypeVariable__List_TypeVariable__value; 477 } 478 /** 479 * @attribute inh 480 * @aspect LookupMethod 481 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupMethod.jrag:40 482 */ 483 /** 484 * @attribute inh 485 * @aspect LookupMethod 486 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupMethod.jrag:40 487 */ 488 @ASTNodeAnnotation.Attribute 489 public Expr nestedScope() { 490 Expr nestedScope_value = getParent().Define_nestedScope(this, null); 491 492 return nestedScope_value; 493 } 494 /** 495 * @attribute inh 496 * @aspect TypeScopePropagation 497 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:289 498 */ 499 /** 500 * @attribute inh 501 * @aspect TypeScopePropagation 502 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:289 503 */ 504 @ASTNodeAnnotation.Attribute 505 public TypeDecl unknownType() { 506 TypeDecl unknownType_value = getParent().Define_unknownType(this, null); 507 508 return unknownType_value; 509 } 510 /** 511 * @attribute inh 512 * @aspect VariableScopePropagation 513 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:334 514 */ 515 /** 516 * @attribute inh 517 * @aspect VariableScopePropagation 518 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:334 519 */ 520 @ASTNodeAnnotation.Attribute 521 public Variable unknownField() { 522 Variable unknownField_value = getParent().Define_unknownField(this, null); 523 524 return unknownField_value; 525 } 526 /** 527 * @attribute inh 528 * @aspect CreateBCode 529 * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:561 530 */ 531 /** 532 * @attribute inh 533 * @aspect CreateBCode 534 * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:561 535 */ 536 @ASTNodeAnnotation.Attribute 537 public boolean inExplicitConstructorInvocation() { 538 boolean inExplicitConstructorInvocation_value = getParent().Define_inExplicitConstructorInvocation(this, null); 539 540 return inExplicitConstructorInvocation_value; 541 } 542 /** 543 * @attribute inh 544 * @aspect Annotations 545 * @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:340 546 */ 547 /** 548 * @attribute inh 549 * @aspect Annotations 550 * @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:340 551 */ 552 @ASTNodeAnnotation.Attribute 553 public boolean withinSuppressWarnings(String annot) { 554 boolean withinSuppressWarnings_String_value = getParent().Define_withinSuppressWarnings(this, null, annot); 555 556 return withinSuppressWarnings_String_value; 557 } 558 /** 559 * @attribute inh 560 * @aspect Annotations 561 * @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:448 562 */ 563 /** 564 * @attribute inh 565 * @aspect Annotations 566 * @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:448 567 */ 568 @ASTNodeAnnotation.Attribute 569 public boolean withinDeprecatedAnnotation() { 570 boolean withinDeprecatedAnnotation_value = getParent().Define_withinDeprecatedAnnotation(this, null); 571 572 return withinDeprecatedAnnotation_value; 573 } 574 /** 575 * @apilevel internal 576 */ 577 public ASTNode rewriteTo() { 578 return super.rewriteTo(); 579 } 580 }