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 * Represents a single character. 015 * May not contain a Unicode escape sequence (Unicode escapes 016 * are transcoded by the scanner). 017 * @production CharacterLiteral : {@link Literal}; 018 * @ast node 019 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/Literals.ast:30 020 */ 021 public class CharacterLiteral extends Literal implements Cloneable { 022 /** 023 * @apilevel low-level 024 */ 025 public void flushCache() { 026 } 027 /** 028 * @apilevel internal 029 */ 030 public void flushCollectionCache() { 031 } 032 /** 033 * @apilevel internal 034 */ 035 @SuppressWarnings({"unchecked", "cast"}) 036 public CharacterLiteral clone() throws CloneNotSupportedException { 037 CharacterLiteral node = (CharacterLiteral)super.clone(); 038 node.constant_computed = false; 039 node.constant_value = null; 040 node.type_computed = false; 041 node.type_value = null; 042 node.in$Circle(false); 043 node.is$Final(false); 044 return node; 045 } 046 /** 047 * @apilevel internal 048 */ 049 @SuppressWarnings({"unchecked", "cast"}) 050 public CharacterLiteral copy() { 051 052 try { 053 CharacterLiteral node = (CharacterLiteral) clone(); 054 node.parent = null; 055 if(children != null) 056 node.children = (ASTNode[]) children.clone(); 057 058 return node; 059 } catch (CloneNotSupportedException e) { 060 throw new Error("Error: clone not supported for " + getClass().getName()); 061 } 062 063 }/** 064 * Create a deep copy of the AST subtree at this node. 065 * The copy is dangling, i.e. has no parent. 066 * @return dangling copy of the subtree at this node 067 * @apilevel low-level 068 */ 069 @SuppressWarnings({"unchecked", "cast"}) 070 public CharacterLiteral fullCopy() { 071 072 CharacterLiteral tree = (CharacterLiteral) copy(); 073 if (children != null) { 074 for (int i = 0; i < children.length; ++i) { 075 076 ASTNode child = (ASTNode) children[i]; 077 if(child != null) { 078 child = child.fullCopy(); 079 tree.setChild(child, i); 080 } 081 } 082 } 083 return tree; 084 085 } /** 086 * @ast method 087 * @aspect PrettyPrint 088 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/PrettyPrint.jadd:271 089 */ 090 public void toString(StringBuffer s) { 091 s.append("'" + escape(getLITERAL()) + "'"); 092 } 093 /** 094 * @ast method 095 * @aspect CodeGeneration 096 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:558 097 */ 098 public void emitPushConstant(CodeGeneration gen) { 099 type().emitPushConstant(gen, constant().intValue()); 100 } 101 /** 102 * @ast method 103 * 104 */ 105 public CharacterLiteral() { 106 super(); 107 108 109 } 110 /** 111 * Initializes the child array to the correct size. 112 * Initializes List and Opt nta children. 113 * @apilevel internal 114 * @ast method 115 * @ast method 116 * 117 */ 118 public void init$Children() { 119 } 120 /** 121 * @ast method 122 * 123 */ 124 public CharacterLiteral(String p0) { 125 setLITERAL(p0); 126 } 127 /** 128 * @ast method 129 * 130 */ 131 public CharacterLiteral(beaver.Symbol p0) { 132 setLITERAL(p0); 133 } 134 /** 135 * @apilevel low-level 136 * @ast method 137 * 138 */ 139 protected int numChildren() { 140 return 0; 141 } 142 /** 143 * @apilevel internal 144 * @ast method 145 * 146 */ 147 public boolean mayHaveRewrite() { 148 return false; 149 } 150 /** 151 * Replaces the lexeme LITERAL. 152 * @param value The new value for the lexeme LITERAL. 153 * @apilevel high-level 154 * @ast method 155 * 156 */ 157 public void setLITERAL(String value) { 158 tokenString_LITERAL = value; 159 } 160 /** 161 * JastAdd-internal setter for lexeme LITERAL using the Beaver parser. 162 * @apilevel internal 163 * @ast method 164 * 165 */ 166 public void setLITERAL(beaver.Symbol symbol) { 167 if(symbol.value != null && !(symbol.value instanceof String)) 168 throw new UnsupportedOperationException("setLITERAL is only valid for String lexemes"); 169 tokenString_LITERAL = (String)symbol.value; 170 LITERALstart = symbol.getStart(); 171 LITERALend = symbol.getEnd(); 172 } 173 /** 174 * Retrieves the value for the lexeme LITERAL. 175 * @return The value for the lexeme LITERAL. 176 * @apilevel high-level 177 * @ast method 178 * 179 */ 180 public String getLITERAL() { 181 return tokenString_LITERAL != null ? tokenString_LITERAL : ""; 182 } 183 /** 184 * @apilevel internal 185 */ 186 protected boolean constant_computed = false; 187 /** 188 * @apilevel internal 189 */ 190 protected Constant constant_value; 191 /** 192 * @attribute syn 193 * @aspect ConstantExpression 194 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/ConstantExpression.jrag:157 195 */ 196 @SuppressWarnings({"unchecked", "cast"}) 197 public Constant constant() { 198 if(constant_computed) { 199 return constant_value; 200 } 201 ASTNode$State state = state(); 202 int num = state.boundariesCrossed; 203 boolean isFinal = this.is$Final(); 204 constant_value = constant_compute(); 205 if(isFinal && num == state().boundariesCrossed){ constant_computed = true; } 206 return constant_value; 207 } 208 /** 209 * @apilevel internal 210 */ 211 private Constant constant_compute() { return Constant.create(getLITERAL().charAt(0)); } 212 /** 213 * @apilevel internal 214 */ 215 protected boolean type_computed = false; 216 /** 217 * @apilevel internal 218 */ 219 protected TypeDecl type_value; 220 /** 221 * @attribute syn 222 * @aspect TypeAnalysis 223 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:305 224 */ 225 @SuppressWarnings({"unchecked", "cast"}) 226 public TypeDecl type() { 227 if(type_computed) { 228 return type_value; 229 } 230 ASTNode$State state = state(); 231 int num = state.boundariesCrossed; 232 boolean isFinal = this.is$Final(); 233 type_value = type_compute(); 234 if(isFinal && num == state().boundariesCrossed){ type_computed = true; } 235 return type_value; 236 } 237 /** 238 * @apilevel internal 239 */ 240 private TypeDecl type_compute() { return typeChar(); } 241 /** 242 * @apilevel internal 243 */ 244 public ASTNode rewriteTo() { 245 return super.rewriteTo(); 246 } 247 }