1 19 20 package soot.dava.internal.javaRep; 21 22 import soot.*; 23 import soot.jimple.*; 24 25 public class DIntConstant extends IntConstant 26 { 27 public Type type; 28 29 private DIntConstant(int value, Type type) 30 { 31 super( value); 32 this.type = type; 33 } 34 35 public static DIntConstant v(int value, Type type) 36 { 37 return new DIntConstant(value, type); 38 } 39 40 public String toString() 41 { 42 if (type != null) 43 44 if (type instanceof BooleanType) { 45 if (value == 0) 46 return "false"; 47 else 48 return "true"; 49 } 50 51 else if (type instanceof CharType) { 52 String ch = ""; 53 54 switch (value) { 55 56 case 0x08: ch = "\\b"; break; 57 case 0x09: ch = "\\t"; break; 58 case 0x0a: ch = "\\n"; break; 59 case 0x0c: ch = "\\f"; break; 60 case 0x0d: ch = "\\r"; break; 61 case 0x22: ch = "\\\""; break; 62 case 0x27: ch = "\\'"; break; 63 case 0x5c: ch = "\\\\"; break; 64 65 default: 66 if ((value > 31) && (value < 127)) 67 ch = new Character ( (char) value).toString(); 68 69 else { 70 ch = Integer.toHexString( value); 71 72 while (ch.length() < 4) 73 ch = "0" + ch; 74 75 if (ch.length() > 4) 76 ch = ch.substring( ch.length() - 4); 77 78 ch = "\\u" + ch; 79 } 80 } 81 82 return "'" + ch + "'"; 83 } 84 85 else if (type instanceof ByteType) 86 return "(byte) " + new Integer (value).toString(); 87 88 return new Integer (value).toString(); 89 } 90 } 91 | Popular Tags |