1 19 20 25 26 27 28 29 30 package soot.jimple; 31 32 import soot.*; 33 import soot.util.*; 34 import java.util.*; 35 36 public class LongConstant extends ArithmeticConstant 37 { 38 public final long value; 39 40 private LongConstant(long value) 41 { 42 this.value = value; 43 } 44 45 public static LongConstant v(long value) 46 { 47 return new LongConstant(value); 48 } 49 50 public boolean equals(Object c) 51 { 52 return c instanceof LongConstant && ((LongConstant) c).value == this.value; 53 } 54 55 56 public int hashCode() 57 { 58 return (int)(value^(value>>>32)); 59 } 60 61 public NumericConstant add(NumericConstant c) 63 { 64 if (!(c instanceof LongConstant)) 65 throw new IllegalArgumentException ("LongConstant expected"); 66 return LongConstant.v(this.value + ((LongConstant)c).value); 67 } 68 69 public NumericConstant subtract(NumericConstant c) 70 { 71 if (!(c instanceof LongConstant)) 72 throw new IllegalArgumentException ("LongConstant expected"); 73 return LongConstant.v(this.value - ((LongConstant)c).value); 74 } 75 76 public NumericConstant multiply(NumericConstant c) 77 { 78 if (!(c instanceof LongConstant)) 79 throw new IllegalArgumentException ("LongConstant expected"); 80 return LongConstant.v(this.value * ((LongConstant)c).value); 81 } 82 83 public NumericConstant divide(NumericConstant c) 84 { 85 if (!(c instanceof LongConstant)) 86 throw new IllegalArgumentException ("LongConstant expected"); 87 return LongConstant.v(this.value / ((LongConstant)c).value); 88 } 89 90 public NumericConstant remainder(NumericConstant c) 91 { 92 if (!(c instanceof LongConstant)) 93 throw new IllegalArgumentException ("LongConstant expected"); 94 return LongConstant.v(this.value % ((LongConstant)c).value); 95 } 96 97 public NumericConstant equalEqual(NumericConstant c) 98 { 99 if (!(c instanceof LongConstant)) 100 throw new IllegalArgumentException ("LongConstant expected"); 101 return IntConstant.v((this.value == ((LongConstant)c).value) ? 1 : 0); 102 } 103 104 public NumericConstant notEqual(NumericConstant c) 105 { 106 if (!(c instanceof LongConstant)) 107 throw new IllegalArgumentException ("LongConstant expected"); 108 return IntConstant.v((this.value != ((LongConstant)c).value) ? 1 : 0); 109 } 110 111 public NumericConstant lessThan(NumericConstant c) 112 { 113 if (!(c instanceof LongConstant)) 114 throw new IllegalArgumentException ("LongConstant expected"); 115 return IntConstant.v((this.value < ((LongConstant)c).value) ? 1 : 0); 116 } 117 118 public NumericConstant lessThanOrEqual(NumericConstant c) 119 { 120 if (!(c instanceof LongConstant)) 121 throw new IllegalArgumentException ("LongConstant expected"); 122 return IntConstant.v((this.value <= ((LongConstant)c).value) ? 1 : 0); 123 } 124 125 public NumericConstant greaterThan(NumericConstant c) 126 { 127 if (!(c instanceof LongConstant)) 128 throw new IllegalArgumentException ("LongConstant expected"); 129 return IntConstant.v((this.value > ((LongConstant)c).value) ? 1 : 0); 130 } 131 132 public NumericConstant greaterThanOrEqual(NumericConstant c) 133 { 134 if (!(c instanceof LongConstant)) 135 throw new IllegalArgumentException ("LongConstant expected"); 136 return IntConstant.v((this.value >= ((LongConstant)c).value) ? 1 : 0); 137 } 138 139 public IntConstant cmp(LongConstant c) { 140 if (this.value > c.value) 141 return IntConstant.v(1); 142 else if (this.value == c.value) 143 return IntConstant.v(0); 144 else 145 return IntConstant.v(-1); 146 } 147 148 public NumericConstant negate() 149 { 150 return LongConstant.v(-(this.value)); 151 } 152 153 public ArithmeticConstant and(ArithmeticConstant c) 154 { 155 if (!(c instanceof LongConstant)) 156 throw new IllegalArgumentException ("LongConstant expected"); 157 return LongConstant.v(this.value & ((LongConstant)c).value); 158 } 159 160 public ArithmeticConstant or(ArithmeticConstant c) 161 { 162 if (!(c instanceof LongConstant)) 163 throw new IllegalArgumentException ("LongConstant expected"); 164 return LongConstant.v(this.value | ((LongConstant)c).value); 165 } 166 167 public ArithmeticConstant xor(ArithmeticConstant c) 168 { 169 if (!(c instanceof LongConstant)) 170 throw new IllegalArgumentException ("LongConstant expected"); 171 return LongConstant.v(this.value ^ ((LongConstant)c).value); 172 } 173 174 public ArithmeticConstant shiftLeft(ArithmeticConstant c) 175 { 176 179 if (!(c instanceof IntConstant)) 180 throw new IllegalArgumentException ("IntConstant expected"); 181 return LongConstant.v(this.value << ((IntConstant)c).value); 182 } 183 184 public ArithmeticConstant shiftRight(ArithmeticConstant c) 185 { 186 if (!(c instanceof IntConstant)) 187 throw new IllegalArgumentException ("IntConstant expected"); 188 return LongConstant.v(this.value >> ((IntConstant)c).value); 189 } 190 191 public ArithmeticConstant unsignedShiftRight(ArithmeticConstant c) 192 { 193 if (!(c instanceof IntConstant)) 194 throw new IllegalArgumentException ("IntConstant expected"); 195 return LongConstant.v(this.value >>> ((IntConstant)c).value); 196 } 197 198 public String toString() 199 { 200 return new Long (value).toString() + "L"; 201 } 202 203 public Type getType() 204 { 205 return LongType.v(); 206 } 207 208 public void apply(Switch sw) 209 { 210 ((ConstantSwitch) sw).caseLongConstant(this); 211 } 212 } 213 214 215 | Popular Tags |