1/* 2 * ProGuard -- shrinking, optimization, obfuscation, and preverification 3 * of Java bytecode. 4 * 5 * Copyright (c) 2002-2009 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 FloatValue represents a specific float value. 25 * 26 * @author Eric Lafortune 27 */ 28abstract class SpecificFloatValue extends FloatValue 29{ 30 // Implementations of unary methods of FloatValue. 31 32 public FloatValue negate() 33 { 34 return new NegatedFloatValue(this); 35 } 36 37 public IntegerValue convertToInteger() 38 { 39 return new ConvertedIntegerValue(this); 40 } 41 42 public LongValue convertToLong() 43 { 44 return new ConvertedLongValue(this); 45 } 46 47 public DoubleValue convertToDouble() 48 { 49 return new ConvertedDoubleValue(this); 50 } 51 52 53 // Implementations of binary methods of FloatValue. 54 55 public FloatValue generalize(FloatValue other) 56 { 57 return other.generalize(this); 58 } 59 60 public FloatValue add(FloatValue other) 61 { 62 return other.add(this); 63 } 64 65 public FloatValue subtract(FloatValue other) 66 { 67 return other.subtractFrom(this); 68 } 69 70 public FloatValue subtractFrom(FloatValue other) 71 { 72 return other.subtract(this); 73 } 74 75 public FloatValue multiply(FloatValue other) 76 { 77 return other.multiply(this); 78 } 79 80 public FloatValue divide(FloatValue other) 81 { 82 return other.divideOf(this); 83 } 84 85 public FloatValue divideOf(FloatValue other) 86 { 87 return other.divide(this); 88 } 89 90 public FloatValue remainder(FloatValue other) 91 { 92 return other.remainderOf(this); 93 } 94 95 public FloatValue remainderOf(FloatValue other) 96 { 97 return other.remainder(this); 98 } 99 100 public IntegerValue compare(FloatValue other) 101 { 102 return other.compareReverse(this); 103 } 104 105 106 // Implementations of binary FloatValue methods with SpecificFloatValue 107 // arguments. 108 109 public FloatValue generalize(SpecificFloatValue other) 110 { 111 return this.equals(other) ? this : ValueFactory.FLOAT_VALUE; 112 } 113 114 public FloatValue add(SpecificFloatValue other) 115 { 116 return new CompositeFloatValue(this, CompositeFloatValue.ADD, other); 117 } 118 119 public FloatValue subtract(SpecificFloatValue other) 120 { 121 return new CompositeFloatValue(this, CompositeFloatValue.SUBTRACT, other); 122 } 123 124 public FloatValue subtractFrom(SpecificFloatValue other) 125 { 126 return new CompositeFloatValue(other, CompositeFloatValue.SUBTRACT, this); 127 } 128 129 public FloatValue multiply(SpecificFloatValue other) 130 { 131 return new CompositeFloatValue(this, CompositeFloatValue.MULTIPLY, other); 132 } 133 134 public FloatValue divide(SpecificFloatValue other) 135 { 136 return new CompositeFloatValue(this, CompositeFloatValue.DIVIDE, other); 137 } 138 139 public FloatValue divideOf(SpecificFloatValue other) 140 { 141 return new CompositeFloatValue(other, CompositeFloatValue.DIVIDE, this); 142 } 143 144 public FloatValue remainder(SpecificFloatValue other) 145 { 146 return new CompositeFloatValue(this, CompositeFloatValue.REMAINDER, other); 147 } 148 149 public FloatValue remainderOf(SpecificFloatValue other) 150 { 151 return new CompositeFloatValue(other, CompositeFloatValue.REMAINDER, this); 152 } 153 154 public IntegerValue compare(SpecificFloatValue other) 155 { 156 return this.equals(other) ? 157 SpecificValueFactory.INTEGER_VALUE_0 : 158 new ComparisonValue(this, other); 159 } 160 161 162 // Implementations for Value. 163 164 public boolean isSpecific() 165 { 166 return true; 167 } 168 169 170 // Implementations for Object. 171 172 public boolean equals(Object object) 173 { 174 return object != null && 175 this.getClass() == object.getClass(); 176 } 177 178 179 public int hashCode() 180 { 181 return this.getClass().hashCode(); 182 } 183} 184