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 VarAccess : {@link Access} ::= <span class="component"><ID:String></span>; 015 * @ast node 016 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/java.ast:19 017 */ 018 public class VarAccess extends Access 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 VarAccess clone() throws CloneNotSupportedException { 034 VarAccess node = (VarAccess)super.clone(); 035 node.isConstant_visited = -1; 036 node.isConstant_computed = false; 037 node.isConstant_initialized = false; 038 node.isDAafter_Variable_values = null; 039 node.decls_computed = false; 040 node.decls_value = null; 041 node.decl_computed = false; 042 node.decl_value = null; 043 node.isFieldAccess_computed = false; 044 node.type_computed = false; 045 node.type_value = null; 046 node.in$Circle(false); 047 node.is$Final(false); 048 return node; 049 } 050 /** 051 * @apilevel internal 052 */ 053 @SuppressWarnings({"unchecked", "cast"}) 054 public VarAccess copy() { 055 056 try { 057 VarAccess node = (VarAccess) clone(); 058 node.parent = null; 059 if(children != null) 060 node.children = (ASTNode[]) children.clone(); 061 062 return node; 063 } catch (CloneNotSupportedException e) { 064 throw new Error("Error: clone not supported for " + getClass().getName()); 065 } 066 067 }/** 068 * Create a deep copy of the AST subtree at this node. 069 * The copy is dangling, i.e. has no parent. 070 * @return dangling copy of the subtree at this node 071 * @apilevel low-level 072 */ 073 @SuppressWarnings({"unchecked", "cast"}) 074 public VarAccess fullCopy() { 075 076 VarAccess tree = (VarAccess) copy(); 077 if (children != null) { 078 for (int i = 0; i < children.length; ++i) { 079 080 ASTNode child = (ASTNode) children[i]; 081 if(child != null) { 082 child = child.fullCopy(); 083 tree.setChild(child, i); 084 } 085 } 086 } 087 return tree; 088 089 } /** 090 * @ast method 091 * @aspect DefiniteAssignment 092 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:94 093 */ 094 public void definiteAssignment() { 095 if(isSource()) { 096 if(decl() instanceof VariableDeclaration) { 097 VariableDeclaration v = (VariableDeclaration)decl(); 098 //System.err.println("Is " + v + " final? " + v.isFinal() + ", DAbefore: " + isDAbefore(v)); 099 if(v.isValue()) { 100 } 101 else if(v.isBlankFinal()) { 102 //if(!isDAbefore(v) && !v.hasInit() && !v.getInit().isConstant()) 103 if(!isDAbefore(v)) 104 error("Final variable " + v.name() + " is not assigned before used"); 105 } 106 else { 107 //if(!v.hasInit() && !isDAbefore(v)) { 108 if(!isDAbefore(v)) 109 error("Local variable " + v.name() + " is not assigned before used"); 110 } 111 } 112 113 else if(decl() instanceof FieldDeclaration && !isQualified()) { 114 FieldDeclaration f = (FieldDeclaration)decl(); 115 //if(f.isFinal() && f.isInstanceVariable() && !isDAbefore(f)) { 116 //if(f.isFinal() && !isDAbefore(f) && (!f.hasInit() || !f.getInit().isConstant())) { 117 //if(f.isFinal() && (!f.hasInit() || !f.getInit().isConstant()) && !isDAbefore(f)) { 118 if(f.isFinal() && !f.hasInit() && !isDAbefore(f)) { 119 error("Final field " + f + " is not assigned before used"); 120 } 121 } 122 123 } 124 if(isDest()) { 125 Variable v = decl(); 126 // Blank final field 127 if(v.isFinal() && v.isBlank() && !hostType().instanceOf(v.hostType())) 128 error("The final variable is not a blank final in this context, so it may not be assigned."); 129 else if(v.isFinal() && isQualified() && (!qualifier().isThisAccess() || ((Access)qualifier()).isQualified())) 130 error("the blank final field " + v.name() + " may only be assigned by simple name"); 131 132 // local variable or parameter 133 else if(v instanceof VariableDeclaration) { 134 VariableDeclaration var = (VariableDeclaration)v; 135 //System.out.println("### is variable"); 136 if(!var.isValue() && var.getParent().getParent().getParent() instanceof SwitchStmt && var.isFinal()) { 137 if(!isDUbefore(var)) 138 error("Final variable " + var.name() + " may only be assigned once"); 139 } 140 else if(var.isValue()) { 141 if(var.hasInit() || !isDUbefore(var)) 142 error("Final variable " + var.name() + " may only be assigned once"); 143 } 144 else if(var.isBlankFinal()) { 145 if(var.hasInit() || !isDUbefore(var)) 146 error("Final variable " + var.name() + " may only be assigned once"); 147 } 148 if(var.isFinal() && (var.hasInit() || !isDUbefore(var))) { 149 //if(var.isFinal() && ((var.hasInit() && var.getInit().isConstant()) || !isDUbefore(var))) { 150 } 151 } 152 // field 153 else if(v instanceof FieldDeclaration) { 154 FieldDeclaration f = (FieldDeclaration)v; 155 if(f.isFinal()) { 156 if(f.hasInit()) 157 error("initialized field " + f.name() + " can not be assigned"); 158 else { 159 BodyDecl bodyDecl = enclosingBodyDecl(); 160 if(!(bodyDecl instanceof ConstructorDecl) && !(bodyDecl instanceof InstanceInitializer) && !(bodyDecl instanceof StaticInitializer) && !(bodyDecl instanceof FieldDeclaration)) 161 error("final field " + f.name() + " may only be assigned in constructors and initializers"); 162 else if(!isDUbefore(f)) 163 error("Final field " + f.name() + " may only be assigned once"); 164 } 165 } 166 } 167 else if(v.isParameter()) { 168 // 8.4.1 169 if(v.isFinal()) { 170 error("Final parameter " + v.name() + " may not be assigned"); 171 } 172 } 173 174 } 175 } 176 /** 177 * @ast method 178 * @aspect DA 179 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:457 180 */ 181 protected boolean checkDUeverywhere(Variable v) { 182 if(isDest() && decl() == v) 183 return false; 184 return super.checkDUeverywhere(v); 185 } 186 /** 187 * @ast method 188 * @aspect NameCheck 189 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/NameCheck.jrag:182 190 */ 191 public void nameCheck() { 192 if(decls().isEmpty() && (!isQualified() || !qualifier().type().isUnknown() || qualifier().isPackageAccess())) 193 error("no field named " + name() + " is accessible"); 194 if(decls().size() > 1) { 195 StringBuffer s = new StringBuffer(); 196 s.append("several fields named " + name()); 197 for(Iterator iter = decls().iterator(); iter.hasNext(); ) { 198 Variable v = (Variable)iter.next(); 199 s.append("\n " + v.type().typeName() + "." + v.name() + " declared in " + v.hostType().typeName()); 200 } 201 error(s.toString()); 202 } 203 204 // 8.8.5.1 205 if(inExplicitConstructorInvocation() && !isQualified() && decl().isInstanceVariable() && hostType() == decl().hostType()) 206 error("instance variable " + name() + " may not be accessed in an explicit constructor invocation"); 207 208 Variable v = decl(); 209 if(!v.isFinal() && !v.isClassVariable() && !v.isInstanceVariable() && v.hostType() != hostType()) 210 error("A parameter/variable used but not declared in an inner class must be declared final"); 211 212 // 8.3.2.3 213 if((decl().isInstanceVariable() || decl().isClassVariable()) && !isQualified()) { 214 if(hostType() != null && !hostType().declaredBeforeUse(decl(), this)) { 215 if(inSameInitializer() && !simpleAssignment() && inDeclaringClass()) { 216 BodyDecl b = closestBodyDecl(hostType()); 217 error("variable " + decl().name() + " is used in " + b + " before it is declared"); 218 } 219 } 220 } 221 222 } 223 /** 224 * @ast method 225 * @aspect NameCheck 226 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/NameCheck.jrag:216 227 */ 228 public BodyDecl closestBodyDecl(TypeDecl t) { 229 ASTNode node = this; 230 while(!(node.getParent().getParent() instanceof Program) && node.getParent().getParent() != t) { 231 node = node.getParent(); 232 } 233 if(node instanceof BodyDecl) 234 return (BodyDecl)node; 235 return null; 236 } 237 /** 238 * @ast method 239 * @aspect NodeConstructors 240 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/NodeConstructors.jrag:38 241 */ 242 public VarAccess(String name, int start, int end) { 243 this(name); 244 this.start = this.IDstart = start; 245 this.end = this.IDend = end; 246 } 247 /** 248 * @ast method 249 * @aspect PrettyPrint 250 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/PrettyPrint.jadd:453 251 */ 252 public void toString(StringBuffer s) { 253 s.append(name()); 254 } 255 /** 256 * @ast method 257 * @aspect CodeGeneration 258 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:699 259 */ 260 public void refined_CodeGeneration_VarAccess_emitStore(CodeGeneration gen) { 261 Variable v = decl(); 262 if(v instanceof VariableDeclaration) { 263 VariableDeclaration decl = (VariableDeclaration)v; 264 if(isDUbefore(v)) 265 gen.addLocalVariableEntryAtCurrentPC(decl.name(), decl.type().typeDescriptor(), decl.localNum(), decl.variableScopeEndLabel(gen)); 266 decl.type().emitStoreLocal(gen, decl.localNum()); 267 } 268 else if(v instanceof ParameterDeclaration) { 269 ParameterDeclaration decl = (ParameterDeclaration)v; 270 decl.type().emitStoreLocal(gen, decl.localNum()); 271 } 272 else if(v instanceof FieldDeclaration) { 273 FieldDeclaration f = (FieldDeclaration)v; 274 if(f.isPrivate() && !hostType().hasField(v.name())) 275 f.createAccessorWrite(fieldQualifierType()).emitInvokeMethod(gen, fieldQualifierType()); 276 else 277 f.emitStoreField(gen, fieldQualifierType()); 278 } 279 } 280 /** 281 * @ast method 282 * @aspect CreateBCode 283 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CreateBCode.jrag:355 284 */ 285 public void createAssignSimpleLoadDest(CodeGeneration gen) { 286 createLoadQualifier(gen); 287 } 288 /** 289 * @ast method 290 * @aspect CreateBCode 291 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CreateBCode.jrag:371 292 */ 293 public void createPushAssignmentResult(CodeGeneration gen) { 294 if(hostType().needsAccessorFor(decl())) 295 return; 296 if(decl().isInstanceVariable()) 297 type().emitDup_x1(gen); 298 else 299 type().emitDup(gen); 300 } 301 /** 302 * @ast method 303 * @aspect CreateBCode 304 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CreateBCode.jrag:389 305 */ 306 public void refined_CreateBCode_VarAccess_createAssignLoadDest(CodeGeneration gen) { 307 createLoadQualifier(gen); 308 Variable v = decl(); 309 if(v.isInstanceVariable()) 310 gen.emitDup(); 311 if(v instanceof VariableDeclaration) { 312 VariableDeclaration decl = (VariableDeclaration)v; 313 decl.type().emitLoadLocal(gen, decl.localNum()); 314 } 315 else if(v instanceof ParameterDeclaration) { 316 ParameterDeclaration decl = (ParameterDeclaration)v; 317 decl.type().emitLoadLocal(gen, decl.localNum()); 318 } 319 else if(v instanceof FieldDeclaration) { 320 FieldDeclaration f = (FieldDeclaration)v; 321 if(requiresAccessor()) 322 f.createAccessor(fieldQualifierType()).emitInvokeMethod(gen, fieldQualifierType()); 323 else 324 f.emitLoadField(gen, fieldQualifierType()); 325 } 326 } 327 /** 328 * @ast method 329 * @aspect CreateBCode 330 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CreateBCode.jrag:438 331 */ 332 public void refined_CreateBCode_VarAccess_createBCode(CodeGeneration gen) { 333 Variable v = decl(); 334 if(v instanceof VariableDeclaration) { 335 VariableDeclaration decl = (VariableDeclaration)v; 336 if(decl.hostType() == hostType()) 337 decl.type().emitLoadLocal(gen, decl.localNum()); 338 else 339 emitLoadLocalInNestedClass(gen, decl); 340 } 341 else if(v instanceof ParameterDeclaration) { 342 ParameterDeclaration decl = (ParameterDeclaration)v; 343 if(decl.hostType() == hostType()) 344 decl.type().emitLoadLocal(gen, decl.localNum()); 345 else 346 emitLoadLocalInNestedClass(gen, decl); 347 } 348 else if(v instanceof FieldDeclaration) { 349 FieldDeclaration f = (FieldDeclaration)v; 350 createLoadQualifier(gen); 351 if(f.isConstant() && (f.type().isPrimitive() || f.type().isString())) { 352 if(!f.isStatic()) 353 fieldQualifierType().emitPop(gen); 354 f.constant().createBCode(gen); 355 } 356 else if(requiresAccessor()) 357 f.createAccessor(fieldQualifierType()).emitInvokeMethod(gen, fieldQualifierType()); 358 else 359 f.emitLoadField(gen, fieldQualifierType()); 360 } 361 } 362 /** 363 * @ast method 364 * @aspect CreateBCode 365 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CreateBCode.jrag:494 366 */ 367 protected void createLoadQualifier(CodeGeneration gen) { 368 Variable v = decl(); 369 if(v instanceof FieldDeclaration) { 370 FieldDeclaration f = (FieldDeclaration)v; 371 if(hasPrevExpr()) { 372 // load explicit qualifier 373 prevExpr().createBCode(gen); 374 // pop qualifier stack element for class variables 375 // this qualifier must be computed to ensure side effects 376 if(!prevExpr().isTypeAccess() && f.isClassVariable()) 377 prevExpr().type().emitPop(gen); 378 } 379 else if(f.isInstanceVariable()) { 380 emitThis(gen, fieldQualifierType()); 381 } 382 } 383 } 384 /** 385 * @ast method 386 * @aspect InnerClasses 387 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/InnerClasses.jrag:25 388 */ 389 private TypeDecl refined_InnerClasses_VarAccess_fieldQualifierType() { 390 if(hasPrevExpr()) 391 return prevExpr().type(); 392 TypeDecl typeDecl = hostType(); 393 while(typeDecl != null && !typeDecl.hasField(name())) 394 typeDecl = typeDecl.enclosingType(); 395 if(typeDecl != null) 396 return typeDecl; 397 return decl().hostType(); 398 } 399 /** 400 * @ast method 401 * @aspect InnerClasses 402 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/InnerClasses.jrag:162 403 */ 404 public void collectEnclosingVariables(HashSet set, TypeDecl typeDecl) { 405 Variable v = decl(); 406 if(!v.isInstanceVariable() && !v.isClassVariable() && v.hostType() == typeDecl) 407 set.add(v); 408 super.collectEnclosingVariables(set, typeDecl); 409 } 410 /** 411 * @ast method 412 * @aspect Transformations 413 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/Transformations.jrag:103 414 */ 415 public void transformation() { 416 Variable v = decl(); 417 if(v instanceof FieldDeclaration) { 418 FieldDeclaration f = (FieldDeclaration)v; 419 if(requiresAccessor()) { 420 TypeDecl typeDecl = fieldQualifierType(); 421 if(isSource()) 422 f.createAccessor(typeDecl); 423 if(isDest()) 424 f.createAccessorWrite(typeDecl); 425 } 426 } 427 super.transformation(); 428 } 429 /** 430 * @ast method 431 * @aspect Annotations 432 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Annotations.jrag:344 433 */ 434 public void checkModifiers() { 435 if(decl() instanceof FieldDeclaration) { 436 FieldDeclaration f = (FieldDeclaration)decl(); 437 if(f.isDeprecated() && 438 !withinDeprecatedAnnotation() && 439 hostType().topLevelType() != f.hostType().topLevelType() && 440 !withinSuppressWarnings("deprecation")) 441 warning(f.name() + " in " + f.hostType().typeName() + " has been deprecated"); 442 } 443 } 444 /** 445 * @ast method 446 * @aspect Enums 447 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Enums.jrag:461 448 */ 449 protected void checkEnum(EnumDecl enumDecl) { 450 super.checkEnum(enumDecl); 451 if(decl().isStatic() && decl().hostType() == enumDecl && !isConstant()) 452 error("may not reference a static field of an enum type from here"); 453 } 454 /** 455 * @ast method 456 * 457 */ 458 public VarAccess() { 459 super(); 460 461 462 } 463 /** 464 * Initializes the child array to the correct size. 465 * Initializes List and Opt nta children. 466 * @apilevel internal 467 * @ast method 468 * @ast method 469 * 470 */ 471 public void init$Children() { 472 } 473 /** 474 * @ast method 475 * 476 */ 477 public VarAccess(String p0) { 478 setID(p0); 479 } 480 /** 481 * @ast method 482 * 483 */ 484 public VarAccess(beaver.Symbol p0) { 485 setID(p0); 486 } 487 /** 488 * @apilevel low-level 489 * @ast method 490 * 491 */ 492 protected int numChildren() { 493 return 0; 494 } 495 /** 496 * @apilevel internal 497 * @ast method 498 * 499 */ 500 public boolean mayHaveRewrite() { 501 return false; 502 } 503 /** 504 * Replaces the lexeme ID. 505 * @param value The new value for the lexeme ID. 506 * @apilevel high-level 507 * @ast method 508 * 509 */ 510 public void setID(String value) { 511 tokenString_ID = value; 512 } 513 /** 514 * @apilevel internal 515 * @ast method 516 * 517 */ 518 519 /** 520 * @apilevel internal 521 */ 522 protected String tokenString_ID; 523 /** 524 * @ast method 525 * 526 */ 527 528 public int IDstart; 529 /** 530 * @ast method 531 * 532 */ 533 534 public int IDend; 535 /** 536 * JastAdd-internal setter for lexeme ID using the Beaver parser. 537 * @apilevel internal 538 * @ast method 539 * 540 */ 541 public void setID(beaver.Symbol symbol) { 542 if(symbol.value != null && !(symbol.value instanceof String)) 543 throw new UnsupportedOperationException("setID is only valid for String lexemes"); 544 tokenString_ID = (String)symbol.value; 545 IDstart = symbol.getStart(); 546 IDend = symbol.getEnd(); 547 } 548 /** 549 * Retrieves the value for the lexeme ID. 550 * @return The value for the lexeme ID. 551 * @apilevel high-level 552 * @ast method 553 * 554 */ 555 public String getID() { 556 return tokenString_ID != null ? tokenString_ID : ""; 557 } 558 /** 559 * @ast method 560 * @aspect GenericsCodegen 561 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/GenericsCodegen.jrag:60 562 */ 563 public void emitStore(CodeGeneration gen) { 564 Variable v = decl(); 565 if(v instanceof FieldDeclaration) { 566 FieldDeclaration f = (FieldDeclaration)v; 567 f = f.erasedField(); 568 if(requiresAccessor()) 569 f.createAccessorWrite(fieldQualifierType()).emitInvokeMethod(gen, fieldQualifierType()); 570 else 571 f.emitStoreField(gen, fieldQualifierType()); 572 } 573 else 574 refined_CodeGeneration_VarAccess_emitStore(gen); 575 } 576 /** 577 * @ast method 578 * @aspect GenericsCodegen 579 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/GenericsCodegen.jrag:73 580 */ 581 public void refined_GenericsCodegen_VarAccess_createAssignLoadDest(CodeGeneration gen) { 582 Variable v = decl(); 583 if(v instanceof FieldDeclaration) { 584 createLoadQualifier(gen); 585 if(v.isInstanceVariable()) 586 gen.emitDup(); 587 FieldDeclaration f = (FieldDeclaration)v; 588 f = f.erasedField(); 589 if(requiresAccessor()) 590 f.createAccessor(fieldQualifierType()).emitInvokeMethod(gen, fieldQualifierType()); 591 else 592 f.emitLoadField(gen, fieldQualifierType()); 593 } 594 else 595 refined_CreateBCode_VarAccess_createAssignLoadDest(gen); 596 } 597 /** 598 * @ast method 599 * @aspect GenericsCodegen 600 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/GenericsCodegen.jrag:90 601 */ 602 public void refined_GenericsCodegen_VarAccess_createBCode(CodeGeneration gen) { 603 Variable v = decl(); 604 if(v instanceof FieldDeclaration) { 605 FieldDeclaration f = (FieldDeclaration)v; 606 f = f.erasedField(); 607 createLoadQualifier(gen); 608 if(f.isConstant() && (f.type().isPrimitive() || f.type().isString())) { 609 if(!f.isStatic()) 610 fieldQualifierType().emitPop(gen); 611 f.constant().createBCode(gen); 612 } 613 else if(requiresAccessor()) 614 f.createAccessor(fieldQualifierType()).emitInvokeMethod(gen, fieldQualifierType()); 615 else 616 f.emitLoadField(gen, fieldQualifierType()); 617 if(f.type() != decl().type()) 618 gen.emitCheckCast(decl().type()); 619 } 620 else 621 refined_CreateBCode_VarAccess_createBCode(gen); 622 } 623 /** 624 * @ast method 625 * @aspect GenericsCodegen 626 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/GenericsCodegen.jrag:160 627 */ 628 protected TypeDecl refined_GenericsCodegen_VarAccess_fieldQualifierType() { 629 TypeDecl typeDecl = refined_InnerClasses_VarAccess_fieldQualifierType(); 630 return typeDecl == null ? null : typeDecl.erasure(); 631 } 632 /** 633 * @ast method 634 * @aspect MultiCatch 635 * @declaredat /home/jesper/svn/JastAddJ/Java7Backend/MultiCatch.jrag:49 636 */ 637 638 public void createAssignLoadDest(CodeGeneration gen) { 639 Variable v = decl(); 640 if (v instanceof CatchParameterDeclaration) { 641 if (v.isInstanceVariable()) 642 gen.emitDup(); 643 CatchParameterDeclaration decl = (CatchParameterDeclaration)v; 644 decl.type().emitLoadLocal(gen, decl.localNum()); 645 } else { 646 refined_GenericsCodegen_VarAccess_createAssignLoadDest(gen); 647 } 648 } 649 /** 650 * @ast method 651 * @aspect MultiCatch 652 * @declaredat /home/jesper/svn/JastAddJ/Java7Backend/MultiCatch.jrag:62 653 */ 654 655 public void createBCode(CodeGeneration gen) { 656 Variable v = decl(); 657 if (v instanceof CatchParameterDeclaration) { 658 CatchParameterDeclaration decl = (CatchParameterDeclaration)v; 659 if (decl.hostType() == hostType()) 660 decl.type().emitLoadLocal(gen, decl.localNum()); 661 else 662 emitLoadLocalInNestedClass(gen, decl); 663 } else { 664 refined_GenericsCodegen_VarAccess_createBCode(gen); 665 } 666 } 667 /** 668 * @ast method 669 * @aspect StaticImportsCodegen 670 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/StaticImportsCodegen.jrag:11 671 */ 672 protected TypeDecl fieldQualifierType() { 673 TypeDecl typeDecl = refined_GenericsCodegen_VarAccess_fieldQualifierType(); 674 if(typeDecl != null) 675 return typeDecl; 676 return decl().hostType(); 677 } 678 /** 679 * @attribute syn 680 * @aspect ConstantExpression 681 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/ConstantExpression.jrag:91 682 */ 683 public Constant constant() { 684 ASTNode$State state = state(); 685 try { return type().cast(decl().getInit().constant()); } 686 finally { 687 } 688 } 689 /** 690 * @apilevel internal 691 */ 692 protected int isConstant_visited = -1; 693 /** 694 * @apilevel internal 695 */ 696 protected boolean isConstant_computed = false; 697 /** 698 * @apilevel internal 699 */ 700 protected boolean isConstant_initialized = false; 701 /** 702 * @apilevel internal 703 */ 704 protected boolean isConstant_value; 705 /** 706 * @attribute syn 707 * @aspect ConstantExpression 708 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/ConstantExpression.jrag:354 709 */ 710 @SuppressWarnings({"unchecked", "cast"}) 711 public boolean isConstant() { 712 if(isConstant_computed) { 713 return isConstant_value; 714 } 715 ASTNode$State state = state(); 716 if (!isConstant_initialized) { 717 isConstant_initialized = true; 718 isConstant_value = false; 719 } 720 if (!state.IN_CIRCLE) { 721 state.IN_CIRCLE = true; 722 int num = state.boundariesCrossed; 723 boolean isFinal = this.is$Final(); 724 do { 725 isConstant_visited = state.CIRCLE_INDEX; 726 state.CHANGE = false; 727 boolean new_isConstant_value = isConstant_compute(); 728 if (new_isConstant_value!=isConstant_value) 729 state.CHANGE = true; 730 isConstant_value = new_isConstant_value; 731 state.CIRCLE_INDEX++; 732 } while (state.CHANGE); 733 if(isFinal && num == state().boundariesCrossed) { 734 isConstant_computed = true; 735 } 736 else { 737 state.RESET_CYCLE = true; 738 isConstant_compute(); 739 state.RESET_CYCLE = false; 740 isConstant_computed = false; 741 isConstant_initialized = false; 742 } 743 state.IN_CIRCLE = false; 744 return isConstant_value; 745 } 746 if(isConstant_visited != state.CIRCLE_INDEX) { 747 isConstant_visited = state.CIRCLE_INDEX; 748 if (state.RESET_CYCLE) { 749 isConstant_computed = false; 750 isConstant_initialized = false; 751 isConstant_visited = -1; 752 return isConstant_value; 753 } 754 boolean new_isConstant_value = isConstant_compute(); 755 if (new_isConstant_value!=isConstant_value) 756 state.CHANGE = true; 757 isConstant_value = new_isConstant_value; 758 return isConstant_value; 759 } 760 return isConstant_value; 761 } 762 /** 763 * @apilevel internal 764 */ 765 private boolean isConstant_compute() { 766 Variable v = decl(); 767 if(v instanceof FieldDeclaration) { 768 FieldDeclaration f = (FieldDeclaration)v; 769 return f.isConstant() && (!isQualified() || (isQualified() && qualifier().isTypeAccess())); 770 } 771 boolean result = v.isFinal() && v.hasInit() && v.getInit().isConstant() && (v.type().isPrimitive() || v.type().isString()); 772 return result && (!isQualified() || (isQualified() && qualifier().isTypeAccess())); 773 } 774 /** 775 * @attribute syn 776 * @aspect DefiniteAssignment 777 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:58 778 */ 779 public Variable varDecl() { 780 ASTNode$State state = state(); 781 try { return decl(); } 782 finally { 783 } 784 } 785 protected java.util.Map isDAafter_Variable_values; 786 /** 787 * @attribute syn 788 * @aspect DA 789 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:351 790 */ 791 @SuppressWarnings({"unchecked", "cast"}) 792 public boolean isDAafter(Variable v) { 793 Object _parameters = v; 794 if(isDAafter_Variable_values == null) isDAafter_Variable_values = new java.util.HashMap(4); 795 if(isDAafter_Variable_values.containsKey(_parameters)) { 796 return ((Boolean)isDAafter_Variable_values.get(_parameters)).booleanValue(); 797 } 798 ASTNode$State state = state(); 799 int num = state.boundariesCrossed; 800 boolean isFinal = this.is$Final(); 801 boolean isDAafter_Variable_value = isDAafter_compute(v); 802 if(isFinal && num == state().boundariesCrossed){ isDAafter_Variable_values.put(_parameters, Boolean.valueOf(isDAafter_Variable_value)); } 803 return isDAafter_Variable_value; 804 } 805 /** 806 * @apilevel internal 807 */ 808 private boolean isDAafter_compute(Variable v) { return isDAbefore(v); } 809 /** 810 * @attribute syn 811 * @aspect DU 812 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:832 813 */ 814 public boolean isDUafter(Variable v) { 815 ASTNode$State state = state(); 816 try { return isDUbefore(v); } 817 finally { 818 } 819 } 820 /** 821 * @attribute syn 822 * @aspect DU 823 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:1196 824 */ 825 public boolean unassignedEverywhere(Variable v, TryStmt stmt) { 826 ASTNode$State state = state(); 827 try { 828 if(isDest() && decl() == v && enclosingStmt().reachable()) { 829 return false; 830 } 831 return super.unassignedEverywhere(v, stmt); 832 } 833 finally { 834 } 835 } 836 /** 837 * @apilevel internal 838 */ 839 protected boolean decls_computed = false; 840 /** 841 * @apilevel internal 842 */ 843 protected SimpleSet decls_value; 844 /** 845 * @attribute syn 846 * @aspect VariableScopePropagation 847 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupVariable.jrag:241 848 */ 849 @SuppressWarnings({"unchecked", "cast"}) 850 public SimpleSet decls() { 851 if(decls_computed) { 852 return decls_value; 853 } 854 ASTNode$State state = state(); 855 int num = state.boundariesCrossed; 856 boolean isFinal = this.is$Final(); 857 decls_value = decls_compute(); 858 if(isFinal && num == state().boundariesCrossed){ decls_computed = true; } 859 return decls_value; 860 } 861 /** 862 * @apilevel internal 863 */ 864 private SimpleSet decls_compute() { 865 SimpleSet set = lookupVariable(name()); 866 if(set.size() == 1) { 867 Variable v = (Variable)set.iterator().next(); 868 if(!isQualified() && inStaticContext()) { 869 if(v.isInstanceVariable() && !hostType().memberFields(v.name()).isEmpty()) 870 return SimpleSet.emptySet; 871 } 872 else if(isQualified() && qualifier().staticContextQualifier()) { 873 if(v.isInstanceVariable()) 874 return SimpleSet.emptySet; 875 } 876 } 877 return set; 878 } 879 /** 880 * @apilevel internal 881 */ 882 protected boolean decl_computed = false; 883 /** 884 * @apilevel internal 885 */ 886 protected Variable decl_value; 887 /** 888 * @attribute syn 889 * @aspect VariableScopePropagation 890 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupVariable.jrag:256 891 */ 892 @SuppressWarnings({"unchecked", "cast"}) 893 public Variable decl() { 894 if(decl_computed) { 895 return decl_value; 896 } 897 ASTNode$State state = state(); 898 int num = state.boundariesCrossed; 899 boolean isFinal = this.is$Final(); 900 decl_value = decl_compute(); 901 if(isFinal && num == state().boundariesCrossed){ decl_computed = true; } 902 return decl_value; 903 } 904 /** 905 * @apilevel internal 906 */ 907 private Variable decl_compute() { 908 SimpleSet decls = decls(); 909 if(decls.size() == 1) 910 return (Variable)decls.iterator().next(); 911 return unknownField(); 912 } 913 /** 914 * @attribute syn 915 * @aspect NameCheck 916 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/NameCheck.jrag:226 917 */ 918 public boolean inSameInitializer() { 919 ASTNode$State state = state(); 920 try { 921 BodyDecl b = closestBodyDecl(decl().hostType()); 922 if(b == null) return false; 923 if(b instanceof FieldDeclaration && ((FieldDeclaration)b).isStatic() == decl().isStatic()) 924 return true; 925 if(b instanceof InstanceInitializer && !decl().isStatic()) 926 return true; 927 if(b instanceof StaticInitializer && decl().isStatic()) 928 return true; 929 return false; 930 } 931 finally { 932 } 933 } 934 /** 935 * @attribute syn 936 * @aspect NameCheck 937 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/NameCheck.jrag:238 938 */ 939 public boolean simpleAssignment() { 940 ASTNode$State state = state(); 941 try { return isDest() && getParent() instanceof AssignSimpleExpr; } 942 finally { 943 } 944 } 945 /** 946 * @attribute syn 947 * @aspect NameCheck 948 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/NameCheck.jrag:240 949 */ 950 public boolean inDeclaringClass() { 951 ASTNode$State state = state(); 952 try { return hostType() == decl().hostType(); } 953 finally { 954 } 955 } 956 /** 957 * @attribute syn 958 * @aspect PrettyPrint 959 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/PrettyPrint.jadd:800 960 */ 961 public String dumpString() { 962 ASTNode$State state = state(); 963 try { return getClass().getName() + " [" + getID() + "]"; } 964 finally { 965 } 966 } 967 /** 968 * @attribute syn 969 * @aspect Names 970 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/QualifiedNames.jrag:17 971 */ 972 public String name() { 973 ASTNode$State state = state(); 974 try { return getID(); } 975 finally { 976 } 977 } 978 /** 979 * @apilevel internal 980 */ 981 protected boolean isFieldAccess_computed = false; 982 /** 983 * @apilevel internal 984 */ 985 protected boolean isFieldAccess_value; 986 /** 987 * @attribute syn 988 * @aspect AccessTypes 989 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ResolveAmbiguousNames.jrag:23 990 */ 991 @SuppressWarnings({"unchecked", "cast"}) 992 public boolean isFieldAccess() { 993 if(isFieldAccess_computed) { 994 return isFieldAccess_value; 995 } 996 ASTNode$State state = state(); 997 int num = state.boundariesCrossed; 998 boolean isFinal = this.is$Final(); 999 isFieldAccess_value = isFieldAccess_compute(); 1000 if(isFinal && num == state().boundariesCrossed){ isFieldAccess_computed = true; } 1001 return isFieldAccess_value; 1002 } 1003 /** 1004 * @apilevel internal 1005 */ 1006 private boolean isFieldAccess_compute() { return decl().isClassVariable() || decl().isInstanceVariable(); } 1007 /** 1008 * @attribute syn 1009 * @aspect SyntacticClassification 1010 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/SyntacticClassification.jrag:56 1011 */ 1012 public NameType predNameType() { 1013 ASTNode$State state = state(); 1014 try { return NameType.AMBIGUOUS_NAME; } 1015 finally { 1016 } 1017 } 1018 /** 1019 * @apilevel internal 1020 */ 1021 protected boolean type_computed = false; 1022 /** 1023 * @apilevel internal 1024 */ 1025 protected TypeDecl type_value; 1026 /** 1027 * @attribute syn 1028 * @aspect TypeAnalysis 1029 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:283 1030 */ 1031 @SuppressWarnings({"unchecked", "cast"}) 1032 public TypeDecl type() { 1033 if(type_computed) { 1034 return type_value; 1035 } 1036 ASTNode$State state = state(); 1037 int num = state.boundariesCrossed; 1038 boolean isFinal = this.is$Final(); 1039 type_value = type_compute(); 1040 if(isFinal && num == state().boundariesCrossed){ type_computed = true; } 1041 return type_value; 1042 } 1043 /** 1044 * @apilevel internal 1045 */ 1046 private TypeDecl type_compute() { return decl().type(); } 1047 /** 1048 * @attribute syn 1049 * @aspect TypeCheck 1050 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeCheck.jrag:15 1051 */ 1052 public boolean isVariable() { 1053 ASTNode$State state = state(); 1054 try { return true; } 1055 finally { 1056 } 1057 } 1058 /** 1059 * @attribute syn 1060 * @aspect CreateBCode 1061 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CreateBCode.jrag:231 1062 */ 1063 public boolean isVarAccessWithAccessor() { 1064 ASTNode$State state = state(); 1065 try { return decl() instanceof FieldDeclaration && 1066 decl().isInstanceVariable() && requiresAccessor(); } 1067 finally { 1068 } 1069 } 1070 /** 1071 * @attribute syn 1072 * @aspect InnerClasses 1073 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/InnerClasses.jrag:373 1074 */ 1075 public boolean requiresAccessor() { 1076 ASTNode$State state = state(); 1077 try { 1078 Variable v = decl(); 1079 if(!(v instanceof FieldDeclaration)) 1080 return false; 1081 FieldDeclaration f = (FieldDeclaration)v; 1082 if(f.isPrivate() && !hostType().hasField(v.name())) 1083 return true; 1084 if(f.isProtected() && !f.hostPackage().equals(hostPackage()) && !hostType().hasField(v.name())) 1085 return true; 1086 return false; 1087 } 1088 finally { 1089 } 1090 } 1091 /** 1092 * @attribute syn 1093 * @aspect Enums 1094 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Enums.jrag:500 1095 */ 1096 public boolean isEnumConstant() { 1097 ASTNode$State state = state(); 1098 try { return varDecl() instanceof EnumConstant; } 1099 finally { 1100 } 1101 } 1102 /** 1103 * @attribute syn 1104 * @aspect PreciseRethrow 1105 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/PreciseRethrow.jrag:11 1106 */ 1107 public Collection<TypeDecl> throwTypes() { 1108 ASTNode$State state = state(); 1109 try { return decl().throwTypes(); } 1110 finally { 1111 } 1112 } 1113 /** 1114 * @attribute syn 1115 * @aspect PreciseRethrow 1116 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/PreciseRethrow.jrag:115 1117 */ 1118 public boolean isVariable(Variable var) { 1119 ASTNode$State state = state(); 1120 try { return decl() == var; } 1121 finally { 1122 } 1123 } 1124 /** 1125 * @attribute inh 1126 * @aspect TypeHierarchyCheck 1127 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeHierarchyCheck.jrag:122 1128 */ 1129 @SuppressWarnings({"unchecked", "cast"}) 1130 public boolean inExplicitConstructorInvocation() { 1131 ASTNode$State state = state(); 1132 boolean inExplicitConstructorInvocation_value = getParent().Define_boolean_inExplicitConstructorInvocation(this, null); 1133 return inExplicitConstructorInvocation_value; 1134 } 1135 /** 1136 * @apilevel internal 1137 */ 1138 public ASTNode rewriteTo() { 1139 return super.rewriteTo(); 1140 } 1141 }