1/* 2 * ProGuard -- shrinking, optimization, obfuscation, and preverification 3 * of Java bytecode. 4 * 5 * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) 6 * 7 * This program is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License as published by the Free 9 * Software Foundation; either version 2 of the License, or (at your option) 10 * any later version. 11 * 12 * This program is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15 * more details. 16 * 17 * You should have received a copy of the GNU General Public License along 18 * with this program; if not, write to the Free Software Foundation, Inc., 19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 */ 21package proguard.evaluation.value; 22 23/** 24 * This LongValue represents a specific long value. 25 * 26 * @author Eric Lafortune 27 */ 28abstract class SpecificLongValue extends LongValue 29{ 30 // Implementations of unary methods of LongValue. 31 32 public LongValue negate() 33 { 34 return new NegatedLongValue(this); 35 } 36 37 public IntegerValue convertToInteger() 38 { 39 return new ConvertedIntegerValue(this); 40 } 41 42 public FloatValue convertToFloat() 43 { 44 return new ConvertedFloatValue(this); 45 } 46 47 public DoubleValue convertToDouble() 48 { 49 return new ConvertedDoubleValue(this); 50 } 51 52 53 // Implementations of binary methods of LongValue. 54 55 public LongValue generalize(LongValue other) 56 { 57 return other.generalize(this); 58 } 59 60 public LongValue add(LongValue other) 61 { 62 return other.add(this); 63 } 64 65 public LongValue subtract(LongValue other) 66 { 67 return other.subtractFrom(this); 68 } 69 70 public LongValue subtractFrom(LongValue other) 71 { 72 return other.subtract(this); 73 } 74 75 public LongValue multiply(LongValue other) 76 { 77 return other.multiply(this); 78 } 79 80 public LongValue divide(LongValue other) 81 throws ArithmeticException 82 { 83 return other.divideOf(this); 84 } 85 86 public LongValue divideOf(LongValue other) 87 throws ArithmeticException 88 { 89 return other.divide(this); 90 } 91 92 public LongValue remainder(LongValue other) 93 throws ArithmeticException 94 { 95 return other.remainderOf(this); 96 } 97 98 public LongValue remainderOf(LongValue other) 99 throws ArithmeticException 100 { 101 return other.remainder(this); 102 } 103 104 public LongValue shiftLeft(IntegerValue other) 105 { 106 return other.shiftLeftOf(this); 107 } 108 109 public LongValue shiftRight(IntegerValue other) 110 { 111 return other.shiftRightOf(this); 112 } 113 114 public LongValue unsignedShiftRight(IntegerValue other) 115 { 116 return other.unsignedShiftRightOf(this); 117 } 118 119 public LongValue and(LongValue other) 120 { 121 return other.and(this); 122 } 123 124 public LongValue or(LongValue other) 125 { 126 return other.or(this); 127 } 128 129 public LongValue xor(LongValue other) 130 { 131 return other.xor(this); 132 } 133 134 public IntegerValue compare(LongValue other) 135 { 136 return other.compareReverse(this); 137 } 138 139 140 // Implementations of binary LongValue methods with SpecificLongValue 141 // arguments. 142 143 public LongValue generalize(SpecificLongValue other) 144 { 145 return this.equals(other) ? this : ValueFactory.LONG_VALUE; 146 } 147 148 public LongValue add(SpecificLongValue other) 149 { 150 return new CompositeLongValue(this, CompositeLongValue.ADD, other); 151 } 152 153 public LongValue subtract(SpecificLongValue other) 154 { 155 return this.equals(other) ? 156 ParticularValueFactory.LONG_VALUE_0 : 157 new CompositeLongValue(this, CompositeLongValue.SUBTRACT, other); 158 } 159 160 public LongValue subtractFrom(SpecificLongValue other) 161 { 162 return this.equals(other) ? 163 ParticularValueFactory.LONG_VALUE_0 : 164 new CompositeLongValue(other, CompositeLongValue.SUBTRACT, this); 165 } 166 167 public LongValue multiply(SpecificLongValue other) 168 { 169 return new CompositeLongValue(this, CompositeLongValue.MULTIPLY, other); 170 } 171 172 public LongValue divide(SpecificLongValue other) 173 throws ArithmeticException 174 { 175 return new CompositeLongValue(this, CompositeLongValue.DIVIDE, other); 176 } 177 178 public LongValue divideOf(SpecificLongValue other) 179 throws ArithmeticException 180 { 181 return new CompositeLongValue(other, CompositeLongValue.DIVIDE, this); 182 } 183 184 public LongValue remainder(SpecificLongValue other) 185 throws ArithmeticException 186 { 187 return new CompositeLongValue(this, CompositeLongValue.REMAINDER, other); 188 } 189 190 public LongValue remainderOf(SpecificLongValue other) 191 throws ArithmeticException 192 { 193 return new CompositeLongValue(other, CompositeLongValue.REMAINDER, this); 194 } 195 196 public LongValue shiftLeft(SpecificLongValue other) 197 { 198 return new CompositeLongValue(this, CompositeLongValue.SHIFT_LEFT, other); 199 } 200 201 public LongValue shiftRight(SpecificLongValue other) 202 { 203 return new CompositeLongValue(this, CompositeLongValue.SHIFT_RIGHT, other); 204 } 205 206 public LongValue unsignedShiftRight(SpecificLongValue other) 207 { 208 return new CompositeLongValue(this, CompositeLongValue.UNSIGNED_SHIFT_RIGHT, other); 209 } 210 211 public LongValue and(SpecificLongValue other) 212 { 213 return this.equals(other) ? 214 this : 215 new CompositeLongValue(other, CompositeLongValue.AND, this); 216 } 217 218 public LongValue or(SpecificLongValue other) 219 { 220 return this.equals(other) ? 221 this : 222 new CompositeLongValue(other, CompositeLongValue.OR, this); 223 } 224 225 public LongValue xor(SpecificLongValue other) 226 { 227 return this.equals(other) ? 228 ParticularValueFactory.LONG_VALUE_0 : 229 new CompositeLongValue(other, CompositeLongValue.XOR, this); 230 } 231 232 public IntegerValue compare(SpecificLongValue other) 233 { 234 return new ComparisonValue(this, other); 235 } 236 237 238 // Implementations for Value. 239 240 public boolean isSpecific() 241 { 242 return true; 243 } 244 245 246 // Implementations for Object. 247 248 public boolean equals(Object object) 249 { 250 return object != null && 251 this.getClass() == object.getClass(); 252 } 253 254 255 public int hashCode() 256 { 257 return this.getClass().hashCode(); 258 } 259} 260