001 /* This file was generated with JastAdd2 (http://jastadd.org) version 2.1.3 */ 002 package AST; 003 004 import java.util.Collection; 005 import java.util.ArrayList; 006 import java.util.HashSet; 007 /** 008 * @ast node 009 * @declaredat /home/csz-naf/examples/PicoJavaMethods/spec/picojava-method.ast:1 010 * @production ReturnStmt : {@link Stmt} ::= <span class="component">{@link Exp}</span>; 011 012 */ 013 public class ReturnStmt extends Stmt implements Cloneable { 014 /** 015 * @apilevel internal 016 */ 017 public ReturnStmt clone() throws CloneNotSupportedException { 018 ReturnStmt node = (ReturnStmt) super.clone(); 019 node.endsWithReturn_visited = -1; 020 node.in$Circle(false); 021 node.is$Final(false); 022 return node; 023 } 024 /** 025 * @apilevel internal 026 */ 027 public ReturnStmt copy() { 028 try { 029 ReturnStmt node = (ReturnStmt) clone(); 030 node.parent = null; 031 if(children != null) { 032 node.children = (ASTNode[]) children.clone(); 033 } 034 return node; 035 } catch (CloneNotSupportedException e) { 036 throw new Error("Error: clone not supported for " + getClass().getName()); 037 } 038 } 039 /** 040 * Create a deep copy of the AST subtree at this node. 041 * The copy is dangling, i.e. has no parent. 042 * @return dangling copy of the subtree at this node 043 * @apilevel low-level 044 */ 045 public ReturnStmt fullCopy() { 046 ReturnStmt tree = (ReturnStmt) copy(); 047 if (children != null) { 048 for (int i = 0; i < children.length; ++i) { 049 ASTNode child = (ASTNode) children[i]; 050 if(child != null) { 051 child = child.fullCopy(); 052 tree.setChild(child, i); 053 } 054 } 055 } 056 return tree; 057 } 058 /** 059 * @aspect PrettyPrint 060 * @declaredat /home/csz-naf/examples/PicoJavaMethods/spec/PrettyPrint.jadd:16 061 */ 062 public void prettyPrint(StringBuilder sb, int t) { 063 sb.append(getIndent(t)).append("return ").append(getExp()).append(";\n"); 064 } 065 /** 066 */ 067 public ReturnStmt() { 068 super(); 069 } 070 /** 071 * Initializes the child array to the correct size. 072 * Initializes List and Opt nta children. 073 * @apilevel internal 074 * @ast method 075 */ 076 public void init$Children() { 077 children = new ASTNode[1]; 078 } 079 /** 080 */ 081 public ReturnStmt(Exp p0) { 082 setChild(p0, 0); 083 } 084 /** 085 * @apilevel low-level 086 */ 087 protected int numChildren() { 088 return 1; 089 } 090 /** 091 * @apilevel internal 092 */ 093 public boolean mayHaveRewrite() { 094 return false; 095 } 096 /** 097 * @apilevel low-level 098 */ 099 public void flushCache() { 100 super.flushCache(); 101 endsWithReturn_visited = -1; 102 } 103 /** 104 * @apilevel internal 105 */ 106 public void flushCollectionCache() { 107 super.flushCollectionCache(); 108 } 109 /** 110 * Replaces the Exp child. 111 * @param node The new node to replace the Exp child. 112 * @apilevel high-level 113 */ 114 public void setExp(Exp node) { 115 setChild(node, 0); 116 } 117 /** 118 * Retrieves the Exp child. 119 * @return The current node used as the Exp child. 120 * @apilevel high-level 121 */ 122 public Exp getExp() { 123 return (Exp) getChild(0); 124 } 125 /** 126 * Retrieves the Exp child. 127 * <p><em>This method does not invoke AST transformations.</em></p> 128 * @return The current node used as the Exp child. 129 * @apilevel low-level 130 */ 131 public Exp getExpNoTransform() { 132 return (Exp) getChildNoTransform(0); 133 } 134 /** 135 * @apilevel internal 136 */ 137 protected int endsWithReturn_visited = -1; 138 /** 139 * @attribute syn 140 * @aspect ErrorCheck 141 * @declaredat /home/csz-naf/examples/PicoJavaMethods/spec/ErrorCheck.jrag:13 142 */ 143 public boolean endsWithReturn() { 144 ASTNode$State state = state(); 145 if (endsWithReturn_visited == state().boundariesCrossed) { 146 throw new RuntimeException("Circular definition of attr: endsWithReturn in class: org.jastadd.ast.AST.SynDecl"); 147 } 148 endsWithReturn_visited = state().boundariesCrossed; 149 try { return true; } 150 finally { 151 endsWithReturn_visited = -1; 152 } 153 } 154 /** 155 * @apilevel internal 156 */ 157 public ASTNode rewriteTo() { return super.rewriteTo(); 158 }}