1 30 31 package oracle.toplink.libraries.asm.tree.analysis; 32 33 import oracle.toplink.libraries.asm.Type; 34 35 42 43 public class BasicValue implements Value { 44 45 public final static Value UNINITIALIZED_VALUE = new BasicValue(null); 46 47 public final static Value INT_VALUE = new BasicValue(Type.INT_TYPE); 48 49 public final static Value FLOAT_VALUE = new BasicValue(Type.FLOAT_TYPE); 50 51 public final static Value LONG_VALUE = new BasicValue(Type.LONG_TYPE); 52 53 public final static Value DOUBLE_VALUE = new BasicValue(Type.DOUBLE_TYPE); 54 55 public final static Value REFERENCE_VALUE = new BasicValue(Type.getType("Ljava/lang/Object;")); 56 57 public final static Value RETURNADDRESS_VALUE = new BasicValue(null); 58 59 private Type type; 60 61 public BasicValue (final Type type) { 62 this.type = type; 63 } 64 65 public Type getType () { 66 return type; 67 } 68 69 public int getSize () { 70 return type == Type.LONG_TYPE || type == Type.DOUBLE_TYPE ? 2 : 1; 71 } 72 73 public boolean isReference () { 74 return type != null && (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY); 75 } 76 77 public boolean equals (final Value value) { 78 if (value == this) { 79 return true; 80 } else if (value instanceof BasicValue) { 81 if (type == null) { 82 return ((BasicValue)value).type == null; 83 } else { 84 return type.equals(((BasicValue)value).type); 85 } 86 } else { 87 return false; 88 } 89 } 90 91 public String toString () { 92 if (this == UNINITIALIZED_VALUE) { 93 return "."; 94 } else if (this == RETURNADDRESS_VALUE) { 95 return "A"; 96 } else if (this == REFERENCE_VALUE) { 97 return "R"; 98 } else { 99 return type.getDescriptor(); 100 } 101 } 102 } | Popular Tags |