1 16 19 20 package org.apache.xalan.xsltc.compiler.util; 21 22 import org.apache.bcel.generic.BranchInstruction; 23 import org.apache.bcel.generic.Instruction; 24 import org.apache.xalan.xsltc.compiler.Constants; 25 import org.apache.xalan.xsltc.compiler.FlowList; 26 import org.apache.xalan.xsltc.compiler.NodeTest; 27 28 33 public abstract class Type implements Constants { 34 public static final Type Int = new IntType(); 35 public static final Type Real = new RealType(); 36 public static final Type Boolean = new BooleanType(); 37 public static final Type NodeSet = new NodeSetType(); 38 public static final Type String = new StringType(); 39 public static final Type ResultTree = new ResultTreeType(); 40 public static final Type Reference = new ReferenceType(); 41 public static final Type Void = new VoidType(); 42 43 public static final Type Object = new ObjectType(java.lang.Object .class); 44 public static final Type ObjectString = new ObjectType(java.lang.String .class); 45 46 public static final Type Node = new NodeType(NodeTest.ANODE); 47 public static final Type Root = new NodeType(NodeTest.ROOT); 48 public static final Type Element = new NodeType(NodeTest.ELEMENT); 49 public static final Type Attribute = new NodeType(NodeTest.ATTRIBUTE); 50 public static final Type Text = new NodeType(NodeTest.TEXT); 51 public static final Type Comment = new NodeType(NodeTest.COMMENT); 52 public static final Type Processing_Instruction = new NodeType(NodeTest.PI); 53 54 58 public static Type newObjectType(String javaClassName) { 59 if (javaClassName == "java.lang.Object") { 60 return Type.Object; 61 } 62 else if (javaClassName == "java.lang.String") { 63 return Type.ObjectString; 64 } 65 else { 66 return new ObjectType(javaClassName); 67 } 68 } 69 70 74 public static Type newObjectType(Class clazz) { 75 if (clazz == java.lang.Object .class) { 76 return Type.Object; 77 } 78 else if (clazz == java.lang.String .class) { 79 return Type.ObjectString; 80 } 81 else { 82 return new ObjectType(clazz); 83 } 84 } 85 86 89 public abstract String toString(); 90 91 94 public abstract boolean identicalTo(Type other); 95 96 99 public boolean isNumber() { 100 return false; 101 } 102 103 107 public boolean implementedAsMethod() { 108 return false; 109 } 110 111 115 public boolean isSimple() { 116 return false; 117 } 118 119 public abstract org.apache.bcel.generic.Type toJCType(); 120 121 126 public int distanceTo(Type type) { 127 return type == this ? 0 : Integer.MAX_VALUE; 128 } 129 130 133 public abstract String toSignature(); 134 135 140 public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, 141 Type type) { 142 ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR, 143 toString(), type.toString()); 144 classGen.getParser().reportError(Constants.FATAL, err); 145 } 146 147 153 public FlowList translateToDesynthesized(ClassGenerator classGen, 154 MethodGenerator methodGen, 155 Type type) { 156 FlowList fl = null; 157 if (type == Type.Boolean) { 158 fl = translateToDesynthesized(classGen, methodGen, 159 (BooleanType)type); 160 } 161 else { 162 translateTo(classGen, methodGen, type); 163 } 164 return fl; 165 } 166 167 172 public FlowList translateToDesynthesized(ClassGenerator classGen, 173 MethodGenerator methodGen, 174 BooleanType type) { 175 ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR, 176 toString(), type.toString()); 177 classGen.getParser().reportError(Constants.FATAL, err); 178 return null; 179 } 180 181 186 public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, 187 Class clazz) { 188 ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR, 189 toString(), clazz.getClass().toString()); 190 classGen.getParser().reportError(Constants.FATAL, err); 191 } 192 193 198 public void translateFrom(ClassGenerator classGen, MethodGenerator methodGen, 199 Class clazz) { 200 ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR, 201 clazz.getClass().toString(), toString()); 202 classGen.getParser().reportError(Constants.FATAL, err); 203 } 204 205 208 public void translateBox(ClassGenerator classGen, 209 MethodGenerator methodGen) { 210 ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR, 211 toString(), "["+toString()+"]"); 212 classGen.getParser().reportError(Constants.FATAL, err); 213 } 214 215 218 public void translateUnBox(ClassGenerator classGen, 219 MethodGenerator methodGen) { 220 ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR, 221 "["+toString()+"]", toString()); 222 classGen.getParser().reportError(Constants.FATAL, err); 223 } 224 225 228 public String getClassName() { 229 return(EMPTYSTRING); 230 } 231 232 public Instruction ADD() { 233 return null; } 235 236 public Instruction SUB() { 237 return null; } 239 240 public Instruction MUL() { 241 return null; } 243 244 public Instruction DIV() { 245 return null; } 247 248 public Instruction REM() { 249 return null; } 251 252 public Instruction NEG() { 253 return null; } 255 256 public Instruction LOAD(int slot) { 257 return null; } 259 260 public Instruction STORE(int slot) { 261 return null; } 263 264 public Instruction POP() { 265 return POP; 266 } 267 268 public BranchInstruction GT(boolean tozero) { 269 return null; } 271 272 public BranchInstruction GE(boolean tozero) { 273 return null; } 275 276 public BranchInstruction LT(boolean tozero) { 277 return null; } 279 280 public BranchInstruction LE(boolean tozero) { 281 return null; } 283 284 public Instruction CMP(boolean less) { 285 return null; } 287 288 public Instruction DUP() { 289 return DUP; } 291 } 292 | Popular Tags |