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 * String literal. 015 * May not contain Unicode escape sequences (Unicode escapes 016 * are transcoded by the scanner). 017 * @production StringLiteral : {@link Literal}; 018 * @ast node 019 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/Literals.ast:37 020 */ 021 public class StringLiteral 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 StringLiteral clone() throws CloneNotSupportedException { 037 StringLiteral node = (StringLiteral)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 StringLiteral copy() { 051 052 try { 053 StringLiteral node = (StringLiteral) 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 StringLiteral fullCopy() { 071 072 StringLiteral tree = (StringLiteral) 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:267 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:530 097 */ 098 public static void push(CodeGeneration gen, String value) { 099 int index = gen.constantPool().addConstant(value); 100 if(index < 256) 101 gen.emit(Bytecode.LDC).add(index); 102 else 103 gen.emit(Bytecode.LDC_W).add2(index); 104 } 105 /** 106 * @ast method 107 * @aspect CodeGeneration 108 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:574 109 */ 110 public void emitPushConstant(CodeGeneration gen) { 111 StringLiteral.push(gen, getLITERAL()); 112 } 113 /** 114 * @ast method 115 * 116 */ 117 public StringLiteral() { 118 super(); 119 120 121 } 122 /** 123 * Initializes the child array to the correct size. 124 * Initializes List and Opt nta children. 125 * @apilevel internal 126 * @ast method 127 * @ast method 128 * 129 */ 130 public void init$Children() { 131 } 132 /** 133 * @ast method 134 * 135 */ 136 public StringLiteral(String p0) { 137 setLITERAL(p0); 138 } 139 /** 140 * @ast method 141 * 142 */ 143 public StringLiteral(beaver.Symbol p0) { 144 setLITERAL(p0); 145 } 146 /** 147 * @apilevel low-level 148 * @ast method 149 * 150 */ 151 protected int numChildren() { 152 return 0; 153 } 154 /** 155 * @apilevel internal 156 * @ast method 157 * 158 */ 159 public boolean mayHaveRewrite() { 160 return false; 161 } 162 /** 163 * Replaces the lexeme LITERAL. 164 * @param value The new value for the lexeme LITERAL. 165 * @apilevel high-level 166 * @ast method 167 * 168 */ 169 public void setLITERAL(String value) { 170 tokenString_LITERAL = value; 171 } 172 /** 173 * JastAdd-internal setter for lexeme LITERAL using the Beaver parser. 174 * @apilevel internal 175 * @ast method 176 * 177 */ 178 public void setLITERAL(beaver.Symbol symbol) { 179 if(symbol.value != null && !(symbol.value instanceof String)) 180 throw new UnsupportedOperationException("setLITERAL is only valid for String lexemes"); 181 tokenString_LITERAL = (String)symbol.value; 182 LITERALstart = symbol.getStart(); 183 LITERALend = symbol.getEnd(); 184 } 185 /** 186 * Retrieves the value for the lexeme LITERAL. 187 * @return The value for the lexeme LITERAL. 188 * @apilevel high-level 189 * @ast method 190 * 191 */ 192 public String getLITERAL() { 193 return tokenString_LITERAL != null ? tokenString_LITERAL : ""; 194 } 195 /** 196 * @apilevel internal 197 */ 198 protected boolean constant_computed = false; 199 /** 200 * @apilevel internal 201 */ 202 protected Constant constant_value; 203 /** 204 * @attribute syn 205 * @aspect ConstantExpression 206 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/ConstantExpression.jrag:158 207 */ 208 @SuppressWarnings({"unchecked", "cast"}) 209 public Constant constant() { 210 if(constant_computed) { 211 return constant_value; 212 } 213 ASTNode$State state = state(); 214 int num = state.boundariesCrossed; 215 boolean isFinal = this.is$Final(); 216 constant_value = constant_compute(); 217 if(isFinal && num == state().boundariesCrossed){ constant_computed = true; } 218 return constant_value; 219 } 220 /** 221 * @apilevel internal 222 */ 223 private Constant constant_compute() { return Constant.create(getLITERAL()); } 224 /** 225 * @apilevel internal 226 */ 227 protected boolean type_computed = false; 228 /** 229 * @apilevel internal 230 */ 231 protected TypeDecl type_value; 232 /** 233 * @attribute syn 234 * @aspect TypeAnalysis 235 * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:306 236 */ 237 @SuppressWarnings({"unchecked", "cast"}) 238 public TypeDecl type() { 239 if(type_computed) { 240 return type_value; 241 } 242 ASTNode$State state = state(); 243 int num = state.boundariesCrossed; 244 boolean isFinal = this.is$Final(); 245 type_value = type_compute(); 246 if(isFinal && num == state().boundariesCrossed){ type_computed = true; } 247 return type_value; 248 } 249 /** 250 * @apilevel internal 251 */ 252 private TypeDecl type_compute() { return typeString(); } 253 /** 254 * @apilevel internal 255 */ 256 public ASTNode rewriteTo() { 257 return super.rewriteTo(); 258 } 259 }