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:206 027 * @production ForStmt : {@link BranchTargetStmt} ::= <span class="component">InitStmt:{@link Stmt}*</span> <span class="component">[Condition:{@link Expr}]</span> <span class="component">UpdateStmt:{@link Stmt}*</span> <span class="component">{@link Stmt}</span>; 028 029 */ 030 public class ForStmt extends BranchTargetStmt implements Cloneable, VariableScope { 031 /** 032 * Manually implemented because it is too complex for a template. 033 * @aspect PrettyPrintUtil 034 * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:91 035 */ 036 public void prettyPrint(PrettyPrinter out) { 037 out.print("for ("); 038 if (getNumInitStmt() > 0) { 039 if (getInitStmt(0) instanceof VarDeclStmt) { 040 VarDeclStmt var = (VarDeclStmt) getInitStmt(0); 041 int minDimension = Integer.MAX_VALUE; 042 for (VariableDeclaration decl : var.getSingleDeclList()) { 043 minDimension = Math.min(minDimension, decl.type().dimension()); 044 } 045 046 // Print type. 047 out.print(var.getModifiers()); 048 out.print(var.type().elementType().typeName()); 049 for (int i = minDimension; i > 0; i--) { 050 out.print("[]"); 051 } 052 053 // Print individual declarations. 054 for (int i = 0; i < var.getNumSingleDecl(); ++i) { 055 if (i != 0) { 056 out.print(","); 057 } 058 VariableDeclaration decl = var.getSingleDecl(i); 059 out.print(" " + decl.name()); 060 for (int j = decl.type().dimension() - minDimension; j > 0; j -= 1) { 061 out.print("[]"); 062 } 063 if (decl.hasInit()) { 064 out.print(" = "); 065 out.print(decl.getInit()); 066 } 067 } 068 } else if (getInitStmt(0) instanceof ExprStmt) { 069 ExprStmt stmt = (ExprStmt) getInitStmt(0); 070 out.print(stmt.getExpr()); 071 for (int i = 1; i < getNumInitStmt(); i++) { 072 out.print(", "); 073 stmt = (ExprStmt)getInitStmt(i); 074 out.print(stmt.getExpr()); 075 } 076 } else { 077 throw new Error("Unexpected initializer in for loop: " + getInitStmt(0)); 078 } 079 } 080 081 out.print("; "); 082 if (hasCondition()) { 083 out.print(getCondition()); 084 } 085 out.print("; "); 086 087 // Print update statements. 088 for (int i = 0; i < getNumUpdateStmt(); i++) { 089 if (i > 0) { 090 out.print(", "); 091 } 092 ExprStmt update = (ExprStmt) getUpdateStmt(i); 093 out.print(update.getExpr()); 094 } 095 096 out.print(") "); 097 if (getStmt() instanceof Block) { 098 out.print(getStmt()); 099 } else { 100 out.print("{"); 101 out.println(); 102 out.indent(1); 103 out.print(getStmt()); 104 out.println(); 105 out.print("}"); 106 } 107 } 108 /** 109 * @aspect TypeCheck 110 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeCheck.jrag:392 111 */ 112 public void typeCheck() { 113 if (hasCondition()) { 114 TypeDecl cond = getCondition().type(); 115 if (!cond.isBoolean()) { 116 errorf("the type of \"%s\" is %s which is not boolean", 117 getCondition().prettyPrint(), cond.name()); 118 } 119 } 120 } 121 /** 122 * @aspect CreateBCode 123 * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:1599 124 */ 125 public void createBCode(CodeGeneration gen) { 126 super.createBCode(gen); 127 for (int i=0; i<getNumInitStmt(); i++) { 128 getInitStmt(i).createBCode(gen); 129 } 130 gen.addLabel(cond_label()); 131 if (!getCondition().isConstant()) { 132 getCondition().branchFalse(gen, end_label()); 133 } 134 if (getCondition().canBeTrue()) { 135 gen.addLabel(begin_label()); 136 getStmt().createBCode(gen); 137 gen.addLabel(update_label()); 138 for (int i=0; i<getNumUpdateStmt(); i++) { 139 getUpdateStmt(i).createBCode(gen); 140 } 141 gen.emitGoto(cond_label()); 142 } 143 gen.addLabel(end_label()); 144 gen.addVariableScopeLabel(variableScopeEndLabel(gen)); 145 } 146 /** 147 * @declaredat ASTNode:1 148 */ 149 public ForStmt() { 150 super(); 151 } 152 /** 153 * Initializes the child array to the correct size. 154 * Initializes List and Opt nta children. 155 * @apilevel internal 156 * @ast method 157 * @declaredat ASTNode:10 158 */ 159 public void init$Children() { 160 children = new ASTNode[4]; 161 setChild(new List(), 0); 162 setChild(new Opt(), 1); 163 setChild(new List(), 2); 164 } 165 /** 166 * @declaredat ASTNode:16 167 */ 168 public ForStmt(List<Stmt> p0, Opt<Expr> p1, List<Stmt> p2, Stmt p3) { 169 setChild(p0, 0); 170 setChild(p1, 1); 171 setChild(p2, 2); 172 setChild(p3, 3); 173 } 174 /** 175 * @apilevel low-level 176 * @declaredat ASTNode:25 177 */ 178 protected int numChildren() { 179 return 4; 180 } 181 /** 182 * @apilevel internal 183 * @declaredat ASTNode:31 184 */ 185 public boolean mayHaveRewrite() { 186 return true; 187 } 188 /** 189 * @apilevel internal 190 * @declaredat ASTNode:37 191 */ 192 public void flushAttrCache() { 193 super.flushAttrCache(); 194 isDAafter_Variable_reset(); 195 isDUafter_Variable_reset(); 196 isDUbeforeCondition_Variable_reset(); 197 localLookup_String_reset(); 198 localVariableDeclaration_String_reset(); 199 canCompleteNormally_reset(); 200 variableScopeEndLabel_CodeGeneration_reset(); 201 cond_label_reset(); 202 begin_label_reset(); 203 update_label_reset(); 204 end_label_reset(); 205 lookupVariable_String_reset(); 206 } 207 /** 208 * @apilevel internal 209 * @declaredat ASTNode:55 210 */ 211 public void flushCollectionCache() { 212 super.flushCollectionCache(); 213 } 214 /** 215 * @apilevel internal 216 * @declaredat ASTNode:61 217 */ 218 public void flushRewriteCache() { 219 super.flushRewriteCache(); 220 } 221 /** 222 * @apilevel internal 223 * @declaredat ASTNode:67 224 */ 225 public ForStmt clone() throws CloneNotSupportedException { 226 ForStmt node = (ForStmt) super.clone(); 227 return node; 228 } 229 /** 230 * @apilevel internal 231 * @declaredat ASTNode:74 232 */ 233 public ForStmt copy() { 234 try { 235 ForStmt node = (ForStmt) clone(); 236 node.parent = null; 237 if (children != null) { 238 node.children = (ASTNode[]) children.clone(); 239 } 240 return node; 241 } catch (CloneNotSupportedException e) { 242 throw new Error("Error: clone not supported for " + getClass().getName()); 243 } 244 } 245 /** 246 * Create a deep copy of the AST subtree at this node. 247 * The copy is dangling, i.e. has no parent. 248 * @return dangling copy of the subtree at this node 249 * @apilevel low-level 250 * @deprecated Please use treeCopy or treeCopyNoTransform instead 251 * @declaredat ASTNode:93 252 */ 253 @Deprecated 254 public ForStmt fullCopy() { 255 return treeCopyNoTransform(); 256 } 257 /** 258 * Create a deep copy of the AST subtree at this node. 259 * The copy is dangling, i.e. has no parent. 260 * @return dangling copy of the subtree at this node 261 * @apilevel low-level 262 * @declaredat ASTNode:103 263 */ 264 public ForStmt treeCopyNoTransform() { 265 ForStmt tree = (ForStmt) copy(); 266 if (children != null) { 267 for (int i = 0; i < children.length; ++i) { 268 ASTNode child = (ASTNode) children[i]; 269 if (child != null) { 270 child = child.treeCopyNoTransform(); 271 tree.setChild(child, i); 272 } 273 } 274 } 275 return tree; 276 } 277 /** 278 * Create a deep copy of the AST subtree at this node. 279 * The subtree of this node is traversed to trigger rewrites before copy. 280 * The copy is dangling, i.e. has no parent. 281 * @return dangling copy of the subtree at this node 282 * @apilevel low-level 283 * @declaredat ASTNode:123 284 */ 285 public ForStmt treeCopy() { 286 doFullTraversal(); 287 return treeCopyNoTransform(); 288 } 289 /** 290 * @apilevel internal 291 * @declaredat ASTNode:130 292 */ 293 protected boolean is$Equal(ASTNode node) { 294 return super.is$Equal(node); 295 } 296 /** 297 * Replaces the InitStmt list. 298 * @param list The new list node to be used as the InitStmt list. 299 * @apilevel high-level 300 */ 301 public void setInitStmtList(List<Stmt> list) { 302 setChild(list, 0); 303 } 304 /** 305 * Retrieves the number of children in the InitStmt list. 306 * @return Number of children in the InitStmt list. 307 * @apilevel high-level 308 */ 309 public int getNumInitStmt() { 310 return getInitStmtList().getNumChild(); 311 } 312 /** 313 * Retrieves the number of children in the InitStmt list. 314 * Calling this method will not trigger rewrites. 315 * @return Number of children in the InitStmt list. 316 * @apilevel low-level 317 */ 318 public int getNumInitStmtNoTransform() { 319 return getInitStmtListNoTransform().getNumChildNoTransform(); 320 } 321 /** 322 * Retrieves the element at index {@code i} in the InitStmt list. 323 * @param i Index of the element to return. 324 * @return The element at position {@code i} in the InitStmt list. 325 * @apilevel high-level 326 */ 327 public Stmt getInitStmt(int i) { 328 return (Stmt) getInitStmtList().getChild(i); 329 } 330 /** 331 * Check whether the InitStmt list has any children. 332 * @return {@code true} if it has at least one child, {@code false} otherwise. 333 * @apilevel high-level 334 */ 335 public boolean hasInitStmt() { 336 return getInitStmtList().getNumChild() != 0; 337 } 338 /** 339 * Append an element to the InitStmt list. 340 * @param node The element to append to the InitStmt list. 341 * @apilevel high-level 342 */ 343 public void addInitStmt(Stmt node) { 344 List<Stmt> list = (parent == null) ? getInitStmtListNoTransform() : getInitStmtList(); 345 list.addChild(node); 346 } 347 /** 348 * @apilevel low-level 349 */ 350 public void addInitStmtNoTransform(Stmt node) { 351 List<Stmt> list = getInitStmtListNoTransform(); 352 list.addChild(node); 353 } 354 /** 355 * Replaces the InitStmt list element at index {@code i} with the new node {@code node}. 356 * @param node The new node to replace the old list element. 357 * @param i The list index of the node to be replaced. 358 * @apilevel high-level 359 */ 360 public void setInitStmt(Stmt node, int i) { 361 List<Stmt> list = getInitStmtList(); 362 list.setChild(node, i); 363 } 364 /** 365 * Retrieves the InitStmt list. 366 * @return The node representing the InitStmt list. 367 * @apilevel high-level 368 */ 369 @ASTNodeAnnotation.ListChild(name="InitStmt") 370 public List<Stmt> getInitStmtList() { 371 List<Stmt> list = (List<Stmt>) getChild(0); 372 return list; 373 } 374 /** 375 * Retrieves the InitStmt list. 376 * <p><em>This method does not invoke AST transformations.</em></p> 377 * @return The node representing the InitStmt list. 378 * @apilevel low-level 379 */ 380 public List<Stmt> getInitStmtListNoTransform() { 381 return (List<Stmt>) getChildNoTransform(0); 382 } 383 /** 384 * Retrieves the InitStmt list. 385 * @return The node representing the InitStmt list. 386 * @apilevel high-level 387 */ 388 public List<Stmt> getInitStmts() { 389 return getInitStmtList(); 390 } 391 /** 392 * Retrieves the InitStmt list. 393 * <p><em>This method does not invoke AST transformations.</em></p> 394 * @return The node representing the InitStmt list. 395 * @apilevel low-level 396 */ 397 public List<Stmt> getInitStmtsNoTransform() { 398 return getInitStmtListNoTransform(); 399 } 400 /** 401 * Replaces the optional node for the Condition child. This is the <code>Opt</code> 402 * node containing the child Condition, not the actual child! 403 * @param opt The new node to be used as the optional node for the Condition child. 404 * @apilevel low-level 405 */ 406 public void setConditionOpt(Opt<Expr> opt) { 407 setChild(opt, 1); 408 } 409 /** 410 * Replaces the (optional) Condition child. 411 * @param node The new node to be used as the Condition child. 412 * @apilevel high-level 413 */ 414 public void setCondition(Expr node) { 415 getConditionOpt().setChild(node, 0); 416 } 417 /** 418 * Check whether the optional Condition child exists. 419 * @return {@code true} if the optional Condition child exists, {@code false} if it does not. 420 * @apilevel high-level 421 */ 422 public boolean hasCondition() { 423 return getConditionOpt().getNumChild() != 0; 424 } 425 /** 426 * Retrieves the (optional) Condition child. 427 * @return The Condition child, if it exists. Returns {@code null} otherwise. 428 * @apilevel low-level 429 */ 430 public Expr getCondition() { 431 return (Expr) getConditionOpt().getChild(0); 432 } 433 /** 434 * Retrieves the optional node for the Condition child. This is the <code>Opt</code> node containing the child Condition, not the actual child! 435 * @return The optional node for child the Condition child. 436 * @apilevel low-level 437 */ 438 @ASTNodeAnnotation.OptChild(name="Condition") 439 public Opt<Expr> getConditionOpt() { 440 return (Opt<Expr>) getChild(1); 441 } 442 /** 443 * Retrieves the optional node for child Condition. This is the <code>Opt</code> node containing the child Condition, not the actual child! 444 * <p><em>This method does not invoke AST transformations.</em></p> 445 * @return The optional node for child Condition. 446 * @apilevel low-level 447 */ 448 public Opt<Expr> getConditionOptNoTransform() { 449 return (Opt<Expr>) getChildNoTransform(1); 450 } 451 /** 452 * Replaces the UpdateStmt list. 453 * @param list The new list node to be used as the UpdateStmt list. 454 * @apilevel high-level 455 */ 456 public void setUpdateStmtList(List<Stmt> list) { 457 setChild(list, 2); 458 } 459 /** 460 * Retrieves the number of children in the UpdateStmt list. 461 * @return Number of children in the UpdateStmt list. 462 * @apilevel high-level 463 */ 464 public int getNumUpdateStmt() { 465 return getUpdateStmtList().getNumChild(); 466 } 467 /** 468 * Retrieves the number of children in the UpdateStmt list. 469 * Calling this method will not trigger rewrites. 470 * @return Number of children in the UpdateStmt list. 471 * @apilevel low-level 472 */ 473 public int getNumUpdateStmtNoTransform() { 474 return getUpdateStmtListNoTransform().getNumChildNoTransform(); 475 } 476 /** 477 * Retrieves the element at index {@code i} in the UpdateStmt list. 478 * @param i Index of the element to return. 479 * @return The element at position {@code i} in the UpdateStmt list. 480 * @apilevel high-level 481 */ 482 public Stmt getUpdateStmt(int i) { 483 return (Stmt) getUpdateStmtList().getChild(i); 484 } 485 /** 486 * Check whether the UpdateStmt list has any children. 487 * @return {@code true} if it has at least one child, {@code false} otherwise. 488 * @apilevel high-level 489 */ 490 public boolean hasUpdateStmt() { 491 return getUpdateStmtList().getNumChild() != 0; 492 } 493 /** 494 * Append an element to the UpdateStmt list. 495 * @param node The element to append to the UpdateStmt list. 496 * @apilevel high-level 497 */ 498 public void addUpdateStmt(Stmt node) { 499 List<Stmt> list = (parent == null) ? getUpdateStmtListNoTransform() : getUpdateStmtList(); 500 list.addChild(node); 501 } 502 /** 503 * @apilevel low-level 504 */ 505 public void addUpdateStmtNoTransform(Stmt node) { 506 List<Stmt> list = getUpdateStmtListNoTransform(); 507 list.addChild(node); 508 } 509 /** 510 * Replaces the UpdateStmt list element at index {@code i} with the new node {@code node}. 511 * @param node The new node to replace the old list element. 512 * @param i The list index of the node to be replaced. 513 * @apilevel high-level 514 */ 515 public void setUpdateStmt(Stmt node, int i) { 516 List<Stmt> list = getUpdateStmtList(); 517 list.setChild(node, i); 518 } 519 /** 520 * Retrieves the UpdateStmt list. 521 * @return The node representing the UpdateStmt list. 522 * @apilevel high-level 523 */ 524 @ASTNodeAnnotation.ListChild(name="UpdateStmt") 525 public List<Stmt> getUpdateStmtList() { 526 List<Stmt> list = (List<Stmt>) getChild(2); 527 return list; 528 } 529 /** 530 * Retrieves the UpdateStmt list. 531 * <p><em>This method does not invoke AST transformations.</em></p> 532 * @return The node representing the UpdateStmt list. 533 * @apilevel low-level 534 */ 535 public List<Stmt> getUpdateStmtListNoTransform() { 536 return (List<Stmt>) getChildNoTransform(2); 537 } 538 /** 539 * Retrieves the UpdateStmt list. 540 * @return The node representing the UpdateStmt list. 541 * @apilevel high-level 542 */ 543 public List<Stmt> getUpdateStmts() { 544 return getUpdateStmtList(); 545 } 546 /** 547 * Retrieves the UpdateStmt list. 548 * <p><em>This method does not invoke AST transformations.</em></p> 549 * @return The node representing the UpdateStmt list. 550 * @apilevel low-level 551 */ 552 public List<Stmt> getUpdateStmtsNoTransform() { 553 return getUpdateStmtListNoTransform(); 554 } 555 /** 556 * Replaces the Stmt child. 557 * @param node The new node to replace the Stmt child. 558 * @apilevel high-level 559 */ 560 public void setStmt(Stmt node) { 561 setChild(node, 3); 562 } 563 /** 564 * Retrieves the Stmt child. 565 * @return The current node used as the Stmt child. 566 * @apilevel high-level 567 */ 568 @ASTNodeAnnotation.Child(name="Stmt") 569 public Stmt getStmt() { 570 return (Stmt) getChild(3); 571 } 572 /** 573 * Retrieves the Stmt child. 574 * <p><em>This method does not invoke AST transformations.</em></p> 575 * @return The current node used as the Stmt child. 576 * @apilevel low-level 577 */ 578 public Stmt getStmtNoTransform() { 579 return (Stmt) getChildNoTransform(3); 580 } 581 /** 582 * @return <code>true</code> if this statement is a potential 583 * branch target of the given branch statement. 584 * @attribute syn 585 * @aspect BranchTarget 586 * @declaredat /home/jesper/git/extendj/java4/frontend/BranchTarget.jrag:217 587 */ 588 @ASTNodeAnnotation.Attribute 589 public boolean potentialTargetOf(Stmt branch) { 590 boolean potentialTargetOf_Stmt_value = branch.canBranchTo(this); 591 592 return potentialTargetOf_Stmt_value; 593 } 594 /** 595 * @apilevel internal 596 */ 597 protected java.util.Map isDAafter_Variable_values; 598 /** 599 * @apilevel internal 600 */ 601 private void isDAafter_Variable_reset() { 602 isDAafter_Variable_values = null; 603 } 604 /** 605 * @attribute syn 606 * @aspect DA 607 * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:257 608 */ 609 @ASTNodeAnnotation.Attribute 610 public boolean isDAafter(Variable v) { 611 Object _parameters = v; 612 if (isDAafter_Variable_values == null) isDAafter_Variable_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 613 ASTNode$State state = state(); 614 if (isDAafter_Variable_values.containsKey(_parameters)) { 615 return (Boolean) isDAafter_Variable_values.get(_parameters); 616 } 617 boolean intermediate = state.INTERMEDIATE_VALUE; 618 state.INTERMEDIATE_VALUE = false; 619 int num = state.boundariesCrossed; 620 boolean isFinal = this.is$Final(); 621 boolean isDAafter_Variable_value = isDAafter_compute(v); 622 if (isFinal && num == state().boundariesCrossed) { 623 isDAafter_Variable_values.put(_parameters, isDAafter_Variable_value); 624 } else { 625 } 626 state.INTERMEDIATE_VALUE |= intermediate; 627 628 return isDAafter_Variable_value; 629 } 630 /** 631 * @apilevel internal 632 */ 633 private boolean isDAafter_compute(Variable v) { 634 if (!(!hasCondition() || getCondition().isDAafterFalse(v))) { 635 return false; 636 } 637 for (Iterator iter = targetBreaks().iterator(); iter.hasNext(); ) { 638 BreakStmt stmt = (BreakStmt) iter.next(); 639 if (!stmt.isDAafterReachedFinallyBlocks(v)) { 640 return false; 641 } 642 } 643 return true; 644 } 645 /** 646 * @attribute syn 647 * @aspect DA 648 * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:703 649 */ 650 @ASTNodeAnnotation.Attribute 651 public boolean isDAafterInitialization(Variable v) { 652 boolean isDAafterInitialization_Variable_value = getNumInitStmt() == 0 ? isDAbefore(v) : getInitStmt(getNumInitStmt()-1).isDAafter(v); 653 654 return isDAafterInitialization_Variable_value; 655 } 656 /** 657 * @apilevel internal 658 */ 659 protected java.util.Map isDUafter_Variable_values; 660 /** 661 * @apilevel internal 662 */ 663 private void isDUafter_Variable_reset() { 664 isDUafter_Variable_values = null; 665 } 666 /** 667 * @attribute syn 668 * @aspect DU 669 * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:781 670 */ 671 @ASTNodeAnnotation.Attribute 672 public boolean isDUafter(Variable v) { 673 Object _parameters = v; 674 if (isDUafter_Variable_values == null) isDUafter_Variable_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 675 ASTNode$State state = state(); 676 if (isDUafter_Variable_values.containsKey(_parameters)) { 677 return (Boolean) isDUafter_Variable_values.get(_parameters); 678 } 679 boolean intermediate = state.INTERMEDIATE_VALUE; 680 state.INTERMEDIATE_VALUE = false; 681 int num = state.boundariesCrossed; 682 boolean isFinal = this.is$Final(); 683 boolean isDUafter_Variable_value = isDUafter_compute(v); 684 if (isFinal && num == state().boundariesCrossed) { 685 isDUafter_Variable_values.put(_parameters, isDUafter_Variable_value); 686 } else { 687 } 688 state.INTERMEDIATE_VALUE |= intermediate; 689 690 return isDUafter_Variable_value; 691 } 692 /** 693 * @apilevel internal 694 */ 695 private boolean isDUafter_compute(Variable v) { 696 if (!isDUbeforeCondition(v)) { 697 // start a circular evaluation here 698 return false; 699 } 700 if (!(!hasCondition() || getCondition().isDUafterFalse(v))) { 701 return false; 702 } 703 for (Iterator iter = targetBreaks().iterator(); iter.hasNext(); ) { 704 BreakStmt stmt = (BreakStmt) iter.next(); 705 if (!stmt.isDUafterReachedFinallyBlocks(v)) { 706 return false; 707 } 708 } 709 return true; 710 } 711 /** 712 * @attribute syn 713 * @aspect DU 714 * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:1288 715 */ 716 @ASTNodeAnnotation.Attribute 717 public boolean isDUafterInit(Variable v) { 718 boolean isDUafterInit_Variable_value = getNumInitStmt() == 0 ? isDUbefore(v) : getInitStmt(getNumInitStmt()-1).isDUafter(v); 719 720 return isDUafterInit_Variable_value; 721 } 722 /** 723 * @apilevel internal 724 */ 725 private void isDUbeforeCondition_Variable_reset() { 726 isDUbeforeCondition_Variable_values = null; 727 } 728 protected java.util.Map isDUbeforeCondition_Variable_values; 729 @ASTNodeAnnotation.Attribute 730 public boolean isDUbeforeCondition(Variable v) { 731 Object _parameters = v; 732 if (isDUbeforeCondition_Variable_values == null) isDUbeforeCondition_Variable_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 733 ASTNode$State.CircularValue _value; 734 if (isDUbeforeCondition_Variable_values.containsKey(_parameters)) { 735 Object _o = isDUbeforeCondition_Variable_values.get(_parameters); 736 if (!(_o instanceof ASTNode$State.CircularValue)) { 737 return (Boolean) _o; 738 } else { 739 _value = (ASTNode$State.CircularValue) _o; 740 } 741 } else { 742 _value = new ASTNode$State.CircularValue(); 743 isDUbeforeCondition_Variable_values.put(_parameters, _value); 744 _value.value = true; 745 } 746 ASTNode$State state = state(); 747 boolean new_isDUbeforeCondition_Variable_value; 748 if (!state.IN_CIRCLE) { 749 state.IN_CIRCLE = true; 750 int num = state.boundariesCrossed; 751 boolean isFinal = this.is$Final(); 752 // TODO: fixme 753 // state().CIRCLE_INDEX = 1; 754 do { 755 _value.visited = state.CIRCLE_INDEX; 756 state.CHANGE = false; 757 new_isDUbeforeCondition_Variable_value = isDUbeforeCondition_compute(v); 758 if (new_isDUbeforeCondition_Variable_value != ((Boolean)_value.value)) { 759 state.CHANGE = true; 760 _value.value = new_isDUbeforeCondition_Variable_value; 761 } 762 state.CIRCLE_INDEX++; 763 } while (state.CHANGE); 764 if (isFinal && num == state().boundariesCrossed) { 765 isDUbeforeCondition_Variable_values.put(_parameters, new_isDUbeforeCondition_Variable_value); 766 } else { 767 isDUbeforeCondition_Variable_values.remove(_parameters); 768 state.RESET_CYCLE = true; 769 boolean $tmp = isDUbeforeCondition_compute(v); 770 state.RESET_CYCLE = false; 771 } 772 state.IN_CIRCLE = false; 773 state.INTERMEDIATE_VALUE = false; 774 return new_isDUbeforeCondition_Variable_value; 775 } 776 if (state.CIRCLE_INDEX != _value.visited) { 777 _value.visited = state.CIRCLE_INDEX; 778 new_isDUbeforeCondition_Variable_value = isDUbeforeCondition_compute(v); 779 if (state.RESET_CYCLE) { 780 isDUbeforeCondition_Variable_values.remove(_parameters); 781 } 782 else if (new_isDUbeforeCondition_Variable_value != ((Boolean)_value.value)) { 783 state.CHANGE = true; 784 _value.value = new_isDUbeforeCondition_Variable_value; 785 } 786 state.INTERMEDIATE_VALUE = true; 787 return new_isDUbeforeCondition_Variable_value; 788 } 789 state.INTERMEDIATE_VALUE = true; 790 return (Boolean) _value.value; 791 } 792 /** 793 * @apilevel internal 794 */ 795 private boolean isDUbeforeCondition_compute(Variable v) { 796 if (!isDUafterInit(v)) { 797 return false; 798 } else if (!isDUafterUpdate(v)) { 799 return false; 800 } 801 return true; 802 } 803 /** 804 * @attribute syn 805 * @aspect DU 806 * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:1302 807 */ 808 @ASTNodeAnnotation.Attribute 809 public boolean isDUafterUpdate(Variable v) { 810 { 811 if (!isDUbeforeCondition(v)) // start a circular evaluation here 812 return false; 813 if (getNumUpdateStmt() > 0) { 814 return getUpdateStmt(getNumUpdateStmt()-1).isDUafter(v); 815 } 816 if (!getStmt().isDUafter(v)) { 817 return false; 818 } 819 for (Iterator iter = targetContinues().iterator(); iter.hasNext(); ) { 820 ContinueStmt stmt = (ContinueStmt) iter.next(); 821 if (!stmt.isDUafterReachedFinallyBlocks(v)) { 822 return false; 823 } 824 } 825 return true; 826 } 827 } 828 /** 829 * @apilevel internal 830 */ 831 protected java.util.Map localLookup_String_values; 832 /** 833 * @apilevel internal 834 */ 835 private void localLookup_String_reset() { 836 localLookup_String_values = null; 837 } 838 /** 839 * @attribute syn 840 * @aspect VariableScope 841 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:151 842 */ 843 @ASTNodeAnnotation.Attribute 844 public SimpleSet localLookup(String name) { 845 Object _parameters = name; 846 if (localLookup_String_values == null) localLookup_String_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 847 ASTNode$State state = state(); 848 if (localLookup_String_values.containsKey(_parameters)) { 849 return (SimpleSet) localLookup_String_values.get(_parameters); 850 } 851 boolean intermediate = state.INTERMEDIATE_VALUE; 852 state.INTERMEDIATE_VALUE = false; 853 int num = state.boundariesCrossed; 854 boolean isFinal = this.is$Final(); 855 SimpleSet localLookup_String_value = localLookup_compute(name); 856 if (isFinal && num == state().boundariesCrossed) { 857 localLookup_String_values.put(_parameters, localLookup_String_value); 858 } else { 859 } 860 state.INTERMEDIATE_VALUE |= intermediate; 861 862 return localLookup_String_value; 863 } 864 /** 865 * @apilevel internal 866 */ 867 private SimpleSet localLookup_compute(String name) { 868 VariableDeclaration v = localVariableDeclaration(name); 869 if (v != null) { 870 return v; 871 } 872 return lookupVariable(name); 873 } 874 /** 875 * @apilevel internal 876 */ 877 protected java.util.Map localVariableDeclaration_String_values; 878 /** 879 * @apilevel internal 880 */ 881 private void localVariableDeclaration_String_reset() { 882 localVariableDeclaration_String_values = null; 883 } 884 /** 885 * @attribute syn 886 * @aspect VariableScope 887 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:195 888 */ 889 @ASTNodeAnnotation.Attribute 890 public VariableDeclaration localVariableDeclaration(String name) { 891 Object _parameters = name; 892 if (localVariableDeclaration_String_values == null) localVariableDeclaration_String_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 893 ASTNode$State state = state(); 894 if (localVariableDeclaration_String_values.containsKey(_parameters)) { 895 return (VariableDeclaration) localVariableDeclaration_String_values.get(_parameters); 896 } 897 boolean intermediate = state.INTERMEDIATE_VALUE; 898 state.INTERMEDIATE_VALUE = false; 899 int num = state.boundariesCrossed; 900 boolean isFinal = this.is$Final(); 901 VariableDeclaration localVariableDeclaration_String_value = localVariableDeclaration_compute(name); 902 if (isFinal && num == state().boundariesCrossed) { 903 localVariableDeclaration_String_values.put(_parameters, localVariableDeclaration_String_value); 904 } else { 905 } 906 state.INTERMEDIATE_VALUE |= intermediate; 907 908 return localVariableDeclaration_String_value; 909 } 910 /** 911 * @apilevel internal 912 */ 913 private VariableDeclaration localVariableDeclaration_compute(String name) { 914 for (Stmt stmt: getInitStmtList()) { 915 VariableDeclaration decl = stmt.variableDeclaration(name); 916 if (decl != null) { 917 return decl; 918 } 919 } 920 return null; 921 } 922 /** 923 * @attribute syn 924 * @aspect NameCheck 925 * @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:478 926 */ 927 @ASTNodeAnnotation.Attribute 928 public boolean continueLabel() { 929 boolean continueLabel_value = true; 930 931 return continueLabel_value; 932 } 933 /** 934 * @apilevel internal 935 */ 936 protected boolean canCompleteNormally_computed = false; 937 /** 938 * @apilevel internal 939 */ 940 protected boolean canCompleteNormally_value; 941 /** 942 * @apilevel internal 943 */ 944 private void canCompleteNormally_reset() { 945 canCompleteNormally_computed = false; 946 } 947 /** 948 * @attribute syn 949 * @aspect UnreachableStatements 950 * @declaredat /home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:53 951 */ 952 @ASTNodeAnnotation.Attribute 953 public boolean canCompleteNormally() { 954 ASTNode$State state = state(); 955 if (canCompleteNormally_computed) { 956 return canCompleteNormally_value; 957 } 958 boolean intermediate = state.INTERMEDIATE_VALUE; 959 state.INTERMEDIATE_VALUE = false; 960 int num = state.boundariesCrossed; 961 boolean isFinal = this.is$Final(); 962 canCompleteNormally_value = reachable() && hasCondition() 963 && (!getCondition().isConstant() || !getCondition().isTrue()) || reachableBreak(); 964 if (isFinal && num == state().boundariesCrossed) { 965 canCompleteNormally_computed = true; 966 } else { 967 } 968 state.INTERMEDIATE_VALUE |= intermediate; 969 970 return canCompleteNormally_value; 971 } 972 /** 973 * @apilevel internal 974 */ 975 protected java.util.Map variableScopeEndLabel_CodeGeneration_values; 976 /** 977 * @apilevel internal 978 */ 979 private void variableScopeEndLabel_CodeGeneration_reset() { 980 variableScopeEndLabel_CodeGeneration_values = null; 981 } 982 /** 983 * @attribute syn 984 * @aspect CodeGeneration 985 * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:70 986 */ 987 @ASTNodeAnnotation.Attribute 988 public int variableScopeEndLabel(CodeGeneration gen) { 989 Object _parameters = gen; 990 if (variableScopeEndLabel_CodeGeneration_values == null) variableScopeEndLabel_CodeGeneration_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 991 ASTNode$State state = state(); 992 if (variableScopeEndLabel_CodeGeneration_values.containsKey(_parameters)) { 993 return (Integer) variableScopeEndLabel_CodeGeneration_values.get(_parameters); 994 } 995 boolean intermediate = state.INTERMEDIATE_VALUE; 996 state.INTERMEDIATE_VALUE = false; 997 int num = state.boundariesCrossed; 998 boolean isFinal = this.is$Final(); 999 int variableScopeEndLabel_CodeGeneration_value = gen.variableScopeLabel(); 1000 if (isFinal && num == state().boundariesCrossed) { 1001 variableScopeEndLabel_CodeGeneration_values.put(_parameters, variableScopeEndLabel_CodeGeneration_value); 1002 } else { 1003 } 1004 state.INTERMEDIATE_VALUE |= intermediate; 1005 1006 return variableScopeEndLabel_CodeGeneration_value; 1007 } 1008 /** 1009 * @apilevel internal 1010 */ 1011 protected boolean cond_label_computed = false; 1012 /** 1013 * @apilevel internal 1014 */ 1015 protected int cond_label_value; 1016 /** 1017 * @apilevel internal 1018 */ 1019 private void cond_label_reset() { 1020 cond_label_computed = false; 1021 } 1022 /** 1023 * @attribute syn 1024 * @aspect CreateBCode 1025 * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:1594 1026 */ 1027 @ASTNodeAnnotation.Attribute 1028 public int cond_label() { 1029 ASTNode$State state = state(); 1030 if (cond_label_computed) { 1031 return cond_label_value; 1032 } 1033 boolean intermediate = state.INTERMEDIATE_VALUE; 1034 state.INTERMEDIATE_VALUE = false; 1035 int num = state.boundariesCrossed; 1036 boolean isFinal = this.is$Final(); 1037 cond_label_value = hostType().constantPool().newLabel(); 1038 if (isFinal && num == state().boundariesCrossed) { 1039 cond_label_computed = true; 1040 } else { 1041 } 1042 state.INTERMEDIATE_VALUE |= intermediate; 1043 1044 return cond_label_value; 1045 } 1046 /** 1047 * @apilevel internal 1048 */ 1049 protected boolean begin_label_computed = false; 1050 /** 1051 * @apilevel internal 1052 */ 1053 protected int begin_label_value; 1054 /** 1055 * @apilevel internal 1056 */ 1057 private void begin_label_reset() { 1058 begin_label_computed = false; 1059 } 1060 /** 1061 * @attribute syn 1062 * @aspect CreateBCode 1063 * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:1595 1064 */ 1065 @ASTNodeAnnotation.Attribute 1066 public int begin_label() { 1067 ASTNode$State state = state(); 1068 if (begin_label_computed) { 1069 return begin_label_value; 1070 } 1071 boolean intermediate = state.INTERMEDIATE_VALUE; 1072 state.INTERMEDIATE_VALUE = false; 1073 int num = state.boundariesCrossed; 1074 boolean isFinal = this.is$Final(); 1075 begin_label_value = hostType().constantPool().newLabel(); 1076 if (isFinal && num == state().boundariesCrossed) { 1077 begin_label_computed = true; 1078 } else { 1079 } 1080 state.INTERMEDIATE_VALUE |= intermediate; 1081 1082 return begin_label_value; 1083 } 1084 /** 1085 * @apilevel internal 1086 */ 1087 protected boolean update_label_computed = false; 1088 /** 1089 * @apilevel internal 1090 */ 1091 protected int update_label_value; 1092 /** 1093 * @apilevel internal 1094 */ 1095 private void update_label_reset() { 1096 update_label_computed = false; 1097 } 1098 /** 1099 * @attribute syn 1100 * @aspect CreateBCode 1101 * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:1596 1102 */ 1103 @ASTNodeAnnotation.Attribute 1104 public int update_label() { 1105 ASTNode$State state = state(); 1106 if (update_label_computed) { 1107 return update_label_value; 1108 } 1109 boolean intermediate = state.INTERMEDIATE_VALUE; 1110 state.INTERMEDIATE_VALUE = false; 1111 int num = state.boundariesCrossed; 1112 boolean isFinal = this.is$Final(); 1113 update_label_value = hostType().constantPool().newLabel(); 1114 if (isFinal && num == state().boundariesCrossed) { 1115 update_label_computed = true; 1116 } else { 1117 } 1118 state.INTERMEDIATE_VALUE |= intermediate; 1119 1120 return update_label_value; 1121 } 1122 /** 1123 * @apilevel internal 1124 */ 1125 protected boolean end_label_computed = false; 1126 /** 1127 * @apilevel internal 1128 */ 1129 protected int end_label_value; 1130 /** 1131 * @apilevel internal 1132 */ 1133 private void end_label_reset() { 1134 end_label_computed = false; 1135 } 1136 /** 1137 * @attribute syn 1138 * @aspect CreateBCode 1139 * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:1597 1140 */ 1141 @ASTNodeAnnotation.Attribute 1142 public int end_label() { 1143 ASTNode$State state = state(); 1144 if (end_label_computed) { 1145 return end_label_value; 1146 } 1147 boolean intermediate = state.INTERMEDIATE_VALUE; 1148 state.INTERMEDIATE_VALUE = false; 1149 int num = state.boundariesCrossed; 1150 boolean isFinal = this.is$Final(); 1151 end_label_value = hostType().constantPool().newLabel(); 1152 if (isFinal && num == state().boundariesCrossed) { 1153 end_label_computed = true; 1154 } else { 1155 } 1156 state.INTERMEDIATE_VALUE |= intermediate; 1157 1158 return end_label_value; 1159 } 1160 /** 1161 * @attribute syn 1162 * @aspect CreateBCode 1163 * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:1621 1164 */ 1165 @ASTNodeAnnotation.Attribute 1166 public int break_label() { 1167 int break_label_value = end_label(); 1168 1169 return break_label_value; 1170 } 1171 /** 1172 * @attribute syn 1173 * @aspect CreateBCode 1174 * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:1645 1175 */ 1176 @ASTNodeAnnotation.Attribute 1177 public int continue_label() { 1178 int continue_label_value = update_label(); 1179 1180 return continue_label_value; 1181 } 1182 /** 1183 * @attribute syn 1184 * @aspect PreciseRethrow 1185 * @declaredat /home/jesper/git/extendj/java7/frontend/PreciseRethrow.jrag:84 1186 */ 1187 @ASTNodeAnnotation.Attribute 1188 public boolean modifiedInScope(Variable var) { 1189 { 1190 for (Stmt stmt : getInitStmtList()) { 1191 if (stmt.modifiedInScope(var)) { 1192 return true; 1193 } 1194 } 1195 for (Stmt stmt : getUpdateStmtList()) { 1196 if (stmt.modifiedInScope(var)) { 1197 return true; 1198 } 1199 } 1200 return getStmt().modifiedInScope(var); 1201 } 1202 } 1203 /** 1204 * @attribute inh 1205 * @aspect VariableScope 1206 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:39 1207 */ 1208 /** 1209 * @attribute inh 1210 * @aspect VariableScope 1211 * @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:39 1212 */ 1213 @ASTNodeAnnotation.Attribute 1214 public SimpleSet lookupVariable(String name) { 1215 Object _parameters = name; 1216 if (lookupVariable_String_values == null) lookupVariable_String_values = new org.jastadd.util.RobustMap(new java.util.HashMap()); 1217 ASTNode$State state = state(); 1218 if (lookupVariable_String_values.containsKey(_parameters)) { 1219 return (SimpleSet) lookupVariable_String_values.get(_parameters); 1220 } 1221 boolean intermediate = state.INTERMEDIATE_VALUE; 1222 state.INTERMEDIATE_VALUE = false; 1223 int num = state.boundariesCrossed; 1224 boolean isFinal = this.is$Final(); 1225 SimpleSet lookupVariable_String_value = getParent().Define_lookupVariable(this, null, name); 1226 if (isFinal && num == state().boundariesCrossed) { 1227 lookupVariable_String_values.put(_parameters, lookupVariable_String_value); 1228 } else { 1229 } 1230 state.INTERMEDIATE_VALUE |= intermediate; 1231 1232 return lookupVariable_String_value; 1233 } 1234 /** 1235 * @apilevel internal 1236 */ 1237 protected java.util.Map lookupVariable_String_values; 1238 /** 1239 * @apilevel internal 1240 */ 1241 private void lookupVariable_String_reset() { 1242 lookupVariable_String_values = null; 1243 } 1244 /** 1245 * @declaredat /home/jesper/git/extendj/java4/frontend/BranchTarget.jrag:227 1246 * @apilevel internal 1247 */ 1248 public Stmt Define_branchTarget(ASTNode caller, ASTNode child, Stmt branch) { 1249 int childIndex = this.getIndexOfChild(caller); 1250 return branch.canBranchTo(this) ? this : branchTarget(branch); 1251 } 1252 protected boolean canDefine_branchTarget(ASTNode caller, ASTNode child, Stmt branch) { 1253 return true; 1254 } 1255 /** 1256 * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:255 1257 * @apilevel internal 1258 */ 1259 public boolean Define_isDAbefore(ASTNode caller, ASTNode child, Variable v) { 1260 if (caller == getUpdateStmtListNoTransform()) { 1261 // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:716 1262 int childIndex = caller.getIndexOfChild(child); 1263 { 1264 if (!getStmt().isDAafter(v)) { 1265 return false; 1266 } 1267 for (Iterator iter = targetContinues().iterator(); iter.hasNext(); ) { 1268 ContinueStmt stmt = (ContinueStmt) iter.next(); 1269 if (!stmt.isDAafterReachedFinallyBlocks(v)) { 1270 return false; 1271 } 1272 } 1273 return true; 1274 } 1275 } 1276 else if (caller == getStmtNoTransform()) { 1277 // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:706 1278 { 1279 if (hasCondition() && getCondition().isDAafterTrue(v)) { 1280 return true; 1281 } 1282 if (!hasCondition() && isDAafterInitialization(v)) { 1283 return true; 1284 } 1285 return false; 1286 } 1287 } 1288 else if (caller == getConditionOptNoTransform()) { 1289 // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:704 1290 return isDAafterInitialization(v); 1291 } 1292 else if (caller == getInitStmtListNoTransform()) { 1293 // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:701 1294 int i = caller.getIndexOfChild(child); 1295 return i == 0 ? isDAbefore(v) : getInitStmt(i-1).isDAafter(v); 1296 } 1297 else { 1298 return getParent().Define_isDAbefore(this, caller, v); 1299 } 1300 } 1301 protected boolean canDefine_isDAbefore(ASTNode caller, ASTNode child, Variable v) { 1302 return true; 1303 } 1304 /** 1305 * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:779 1306 * @apilevel internal 1307 */ 1308 public boolean Define_isDUbefore(ASTNode caller, ASTNode child, Variable v) { 1309 if (caller == getUpdateStmtListNoTransform()) { 1310 // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:1321 1311 int i = caller.getIndexOfChild(child); 1312 { 1313 if (!isDUbeforeCondition(v)) // start a circular evaluation here 1314 return false; 1315 if (i == 0) { 1316 if (!getStmt().isDUafter(v)) { 1317 return false; 1318 } 1319 for (Iterator iter = targetContinues().iterator(); iter.hasNext(); ) { 1320 ContinueStmt stmt = (ContinueStmt) iter.next(); 1321 if (!stmt.isDUafterReachedFinallyBlocks(v)) { 1322 return false; 1323 } 1324 } 1325 return true; 1326 } else { 1327 return getUpdateStmt(i-1).isDUafter(v); 1328 } 1329 } 1330 } 1331 else if (caller == getStmtNoTransform()) { 1332 // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:1299 1333 return isDUbeforeCondition(v) && (hasCondition() ? 1334 getCondition().isDUafterTrue(v) : isDUafterInit(v)); 1335 } 1336 else if (caller == getConditionOptNoTransform()) { 1337 // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:1286 1338 return isDUbeforeCondition(v); 1339 } 1340 else if (caller == getInitStmtListNoTransform()) { 1341 // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:1284 1342 int childIndex = caller.getIndexOfChild(child); 1343 return childIndex == 0 ? isDUbefore(v) : getInitStmt(childIndex-1).isDUafter(v); 1344 } 1345 else { 1346 return getParent().Define_isDUbefore(this, caller, v); 1347 } 1348 } 1349 protected boolean canDefine_isDUbefore(ASTNode caller, ASTNode child, Variable v) { 1350 return true; 1351 } 1352 /** 1353 * @declaredat /home/jesper/git/extendj/java8/frontend/LookupVariable.jrag:30 1354 * @apilevel internal 1355 */ 1356 public SimpleSet Define_lookupVariable(ASTNode caller, ASTNode child, String name) { 1357 if (caller == getStmtNoTransform()) { 1358 // @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:150 1359 return localLookup(name); 1360 } 1361 else if (caller == getUpdateStmtListNoTransform()) { 1362 // @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:149 1363 int childIndex = caller.getIndexOfChild(child); 1364 return localLookup(name); 1365 } 1366 else if (caller == getConditionOptNoTransform()) { 1367 // @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:148 1368 return localLookup(name); 1369 } 1370 else if (caller == getInitStmtListNoTransform()) { 1371 // @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:147 1372 int childIndex = caller.getIndexOfChild(child); 1373 return localLookup(name); 1374 } 1375 else { 1376 return getParent().Define_lookupVariable(this, caller, name); 1377 } 1378 } 1379 protected boolean canDefine_lookupVariable(ASTNode caller, ASTNode child, String name) { 1380 return true; 1381 } 1382 /** 1383 * @declaredat /home/jesper/git/extendj/java8/frontend/NameCheck.jrag:30 1384 * @apilevel internal 1385 */ 1386 public VariableScope Define_outerScope(ASTNode caller, ASTNode child) { 1387 if (caller == getStmtNoTransform()) { 1388 // @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:370 1389 return this; 1390 } 1391 else if (caller == getInitStmtListNoTransform()) { 1392 // @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:369 1393 int childIndex = caller.getIndexOfChild(child); 1394 return this; 1395 } 1396 else { 1397 return getParent().Define_outerScope(this, caller); 1398 } 1399 } 1400 protected boolean canDefine_outerScope(ASTNode caller, ASTNode child) { 1401 return true; 1402 } 1403 /** 1404 * @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:441 1405 * @apilevel internal 1406 */ 1407 public boolean Define_insideLoop(ASTNode caller, ASTNode child) { 1408 if (caller == getStmtNoTransform()) { 1409 // @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:445 1410 return true; 1411 } 1412 else { 1413 return getParent().Define_insideLoop(this, caller); 1414 } 1415 } 1416 protected boolean canDefine_insideLoop(ASTNode caller, ASTNode child) { 1417 return true; 1418 } 1419 /** 1420 * @declaredat /home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:52 1421 * @apilevel internal 1422 */ 1423 public boolean Define_reachable(ASTNode caller, ASTNode child) { 1424 if (caller == getStmtNoTransform()) { 1425 // @declaredat /home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:158 1426 return reachable() 1427 && (!hasCondition() || (!getCondition().isConstant() || !getCondition().isFalse())); 1428 } 1429 else { 1430 return getParent().Define_reachable(this, caller); 1431 } 1432 } 1433 protected boolean canDefine_reachable(ASTNode caller, ASTNode child) { 1434 return true; 1435 } 1436 /** 1437 * @declaredat /home/jesper/git/extendj/java7/frontend/PreciseRethrow.jrag:283 1438 * @apilevel internal 1439 */ 1440 public boolean Define_reportUnreachable(ASTNode caller, ASTNode child) { 1441 if (caller == getStmtNoTransform()) { 1442 // @declaredat /home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:213 1443 return reachable(); 1444 } 1445 else { 1446 return getParent().Define_reportUnreachable(this, caller); 1447 } 1448 } 1449 protected boolean canDefine_reportUnreachable(ASTNode caller, ASTNode child) { 1450 return true; 1451 } 1452 /** 1453 * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:67 1454 * @apilevel internal 1455 */ 1456 public int Define_variableScopeEndLabel(ASTNode caller, ASTNode child, CodeGeneration gen) { 1457 if (caller == getInitStmtListNoTransform()) { 1458 // @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:71 1459 int i = caller.getIndexOfChild(child); 1460 return variableScopeEndLabel(gen); 1461 } 1462 else { 1463 return getParent().Define_variableScopeEndLabel(this, caller, gen); 1464 } 1465 } 1466 protected boolean canDefine_variableScopeEndLabel(ASTNode caller, ASTNode child, CodeGeneration gen) { 1467 return true; 1468 } 1469 /** 1470 * @declaredat /home/jesper/git/extendj/java7/backend/MultiCatch.jrag:64 1471 * @apilevel internal 1472 */ 1473 public int Define_localNum(ASTNode caller, ASTNode child) { 1474 if (caller == getInitStmtListNoTransform()) { 1475 // @declaredat /home/jesper/git/extendj/java4/backend/LocalNum.jrag:175 1476 int index = caller.getIndexOfChild(child); 1477 { 1478 if (index == 0) { 1479 return localNum(); 1480 } else { 1481 return getInitStmt(index-1).localNum() + getInitStmt(index-1).localSize(); 1482 } 1483 } 1484 } 1485 else if (caller == getStmtNoTransform()) { 1486 // @declaredat /home/jesper/git/extendj/java4/backend/LocalNum.jrag:166 1487 { 1488 if (getNumInitStmt() == 0) { 1489 return localNum(); 1490 } else { 1491 Stmt last = getInitStmt(getNumInitStmt()-1); 1492 return last.localNum() + last.localSize(); 1493 } 1494 } 1495 } 1496 else { 1497 return getParent().Define_localNum(this, caller); 1498 } 1499 } 1500 protected boolean canDefine_localNum(ASTNode caller, ASTNode child) { 1501 return true; 1502 } 1503 /** 1504 * @declaredat /home/jesper/git/extendj/java8/frontend/EffectivelyFinal.jrag:30 1505 * @apilevel internal 1506 */ 1507 public boolean Define_inhModifiedInScope(ASTNode caller, ASTNode child, Variable var) { 1508 if (caller == getStmtNoTransform()) { 1509 // @declaredat /home/jesper/git/extendj/java8/frontend/EffectivelyFinal.jrag:58 1510 return false; 1511 } 1512 else if (caller == getUpdateStmtListNoTransform()) { 1513 // @declaredat /home/jesper/git/extendj/java8/frontend/EffectivelyFinal.jrag:57 1514 int childIndex = caller.getIndexOfChild(child); 1515 return modifiedInScope(var); 1516 } 1517 else if (caller == getInitStmtListNoTransform()) { 1518 // @declaredat /home/jesper/git/extendj/java8/frontend/EffectivelyFinal.jrag:56 1519 int childIndex = caller.getIndexOfChild(child); 1520 return modifiedInScope(var); 1521 } 1522 else { 1523 return getParent().Define_inhModifiedInScope(this, caller, var); 1524 } 1525 } 1526 protected boolean canDefine_inhModifiedInScope(ASTNode caller, ASTNode child, Variable var) { 1527 return true; 1528 } 1529 /** 1530 * @apilevel internal 1531 */ 1532 public ASTNode rewriteTo() { 1533 // Declared at /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:1341 1534 if (!hasCondition()) { 1535 return rewriteRule0(); 1536 } 1537 return super.rewriteTo(); 1538 } 1539 /** 1540 * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:1341 1541 * @apilevel internal 1542 */ 1543 private ForStmt rewriteRule0() { 1544 { 1545 setCondition(new BooleanLiteral("true")); 1546 return this; 1547 } } 1548 }