1 16 19 20 package com.sun.org.apache.xalan.internal.xsltc.compiler.util; 21 22 import com.sun.org.apache.bcel.internal.generic.BranchInstruction; 23 import com.sun.org.apache.bcel.internal.generic.Instruction; 24 import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants; 25 import com.sun.org.apache.xalan.internal.xsltc.compiler.FlowList; 26 import com.sun.org.apache.xalan.internal.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 java.security.AccessControlContext acc = java.security.AccessController.getContext(); 68 acc.checkPermission(new RuntimePermission ("getContextClassLoader")); 69 70 return new ObjectType(javaClassName); 71 } 72 } 73 74 78 public static Type newObjectType(Class clazz) { 79 if (clazz == java.lang.Object .class) { 80 return Type.Object; 81 } 82 else if (clazz == java.lang.String .class) { 83 return Type.ObjectString; 84 } 85 else { 86 return new ObjectType(clazz); 87 } 88 } 89 90 93 public abstract String toString(); 94 95 98 public abstract boolean identicalTo(Type other); 99 100 103 public boolean isNumber() { 104 return false; 105 } 106 107 111 public boolean implementedAsMethod() { 112 return false; 113 } 114 115 119 public boolean isSimple() { 120 return false; 121 } 122 123 public abstract com.sun.org.apache.bcel.internal.generic.Type toJCType(); 124 125 130 public int distanceTo(Type type) { 131 return type == this ? 0 : Integer.MAX_VALUE; 132 } 133 134 137 public abstract String toSignature(); 138 139 144 public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, 145 Type type) { 146 ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR, 147 toString(), type.toString()); 148 classGen.getParser().reportError(Constants.FATAL, err); 149 } 150 151 157 public FlowList translateToDesynthesized(ClassGenerator classGen, 158 MethodGenerator methodGen, 159 Type type) { 160 FlowList fl = null; 161 if (type == Type.Boolean) { 162 fl = translateToDesynthesized(classGen, methodGen, 163 (BooleanType)type); 164 } 165 else { 166 translateTo(classGen, methodGen, type); 167 } 168 return fl; 169 } 170 171 176 public FlowList translateToDesynthesized(ClassGenerator classGen, 177 MethodGenerator methodGen, 178 BooleanType type) { 179 ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR, 180 toString(), type.toString()); 181 classGen.getParser().reportError(Constants.FATAL, err); 182 return null; 183 } 184 185 190 public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, 191 Class clazz) { 192 ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR, 193 toString(), clazz.getClass().toString()); 194 classGen.getParser().reportError(Constants.FATAL, err); 195 } 196 197 202 public void translateFrom(ClassGenerator classGen, MethodGenerator methodGen, 203 Class clazz) { 204 ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR, 205 clazz.getClass().toString(), toString()); 206 classGen.getParser().reportError(Constants.FATAL, err); 207 } 208 209 212 public void translateBox(ClassGenerator classGen, 213 MethodGenerator methodGen) { 214 ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR, 215 toString(), "["+toString()+"]"); 216 classGen.getParser().reportError(Constants.FATAL, err); 217 } 218 219 222 public void translateUnBox(ClassGenerator classGen, 223 MethodGenerator methodGen) { 224 ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR, 225 "["+toString()+"]", toString()); 226 classGen.getParser().reportError(Constants.FATAL, err); 227 } 228 229 232 public String getClassName() { 233 return(EMPTYSTRING); 234 } 235 236 public Instruction ADD() { 237 return null; } 239 240 public Instruction SUB() { 241 return null; } 243 244 public Instruction MUL() { 245 return null; } 247 248 public Instruction DIV() { 249 return null; } 251 252 public Instruction REM() { 253 return null; } 255 256 public Instruction NEG() { 257 return null; } 259 260 public Instruction LOAD(int slot) { 261 return null; } 263 264 public Instruction STORE(int slot) { 265 return null; } 267 268 public Instruction POP() { 269 return POP; 270 } 271 272 public BranchInstruction GT(boolean tozero) { 273 return null; } 275 276 public BranchInstruction GE(boolean tozero) { 277 return null; } 279 280 public BranchInstruction LT(boolean tozero) { 281 return null; } 283 284 public BranchInstruction LE(boolean tozero) { 285 return null; } 287 288 public Instruction CMP(boolean less) { 289 return null; } 291 292 public Instruction DUP() { 293 return DUP; } 295 } 296 | Popular Tags |