001: /*
002: * ProGuard -- shrinking, optimization, obfuscation, and preverification
003: * of Java bytecode.
004: *
005: * Copyright (c) 2002-2007 Eric Lafortune (eric@graphics.cornell.edu)
006: *
007: * This program is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License as published by the Free
009: * Software Foundation; either version 2 of the License, or (at your option)
010: * any later version.
011: *
012: * This program is distributed in the hope that it will be useful, but WITHOUT
013: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
014: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
015: * more details.
016: *
017: * You should have received a copy of the GNU General Public License along
018: * with this program; if not, write to the Free Software Foundation, Inc.,
019: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: */
021: package proguard.evaluation.value;
022:
023: import proguard.classfile.ClassConstants;
024:
025: /**
026: * This class represents a partially evaluated float value.
027: *
028: * @author Eric Lafortune
029: */
030: public class FloatValue extends Category1Value {
031: /**
032: * Returns the specific float value, if applicable.
033: */
034: public float value() {
035: return 0f;
036: }
037:
038: // Basic binary methods.
039:
040: /**
041: * Returns the generalization of this FloatValue and the given other
042: * FloatValue.
043: */
044: public FloatValue generalize(FloatValue other) {
045: return this ;
046: }
047:
048: /**
049: * Returns the sum of this FloatValue and the given FloatValue.
050: */
051: public FloatValue add(FloatValue other) {
052: return this ;
053: }
054:
055: /**
056: * Returns the difference of this FloatValue and the given FloatValue.
057: */
058: public FloatValue subtract(FloatValue other) {
059: return this ;
060: }
061:
062: /**
063: * Returns the difference of the given FloatValue and this FloatValue.
064: */
065: public FloatValue subtractFrom(FloatValue other) {
066: return this ;
067: }
068:
069: /**
070: * Returns the product of this FloatValue and the given FloatValue.
071: */
072: public FloatValue multiply(FloatValue other) {
073: return this ;
074: }
075:
076: /**
077: * Returns the quotient of this FloatValue and the given FloatValue.
078: */
079: public FloatValue divide(FloatValue other) {
080: return this ;
081: }
082:
083: /**
084: * Returns the quotient of the given FloatValue and this FloatValue.
085: */
086: public FloatValue divideOf(FloatValue other) {
087: return this ;
088: }
089:
090: /**
091: * Returns the remainder of this FloatValue divided by the given FloatValue.
092: */
093: public FloatValue remainder(FloatValue other) {
094: return this ;
095: }
096:
097: /**
098: * Returns the remainder of the given FloatValue divided by this FloatValue.
099: */
100: public FloatValue remainderOf(FloatValue other) {
101: return this ;
102: }
103:
104: /**
105: * Returns an IntegerValue with value -1, 0, or 1, if this FloatValue is
106: * less than, equal to, or greater than the given FloatValue, respectively.
107: */
108: public IntegerValue compare(FloatValue other,
109: ValueFactory valueFactory) {
110: return valueFactory.createIntegerValue();
111: }
112:
113: // Derived binary methods.
114:
115: /**
116: * Returns an IntegerValue with value 1, 0, or -1, if this FloatValue is
117: * less than, equal to, or greater than the given FloatValue, respectively.
118: */
119: public final IntegerValue compareReverse(FloatValue other,
120: ValueFactory valueFactory) {
121: return compare(other, valueFactory).negate();
122: }
123:
124: // Basic unary methods.
125:
126: /**
127: * Returns the negated value of this FloatValue.
128: */
129: public FloatValue negate() {
130: return this ;
131: }
132:
133: /**
134: * Converts this FloatValue to an IntegerValue.
135: */
136: public IntegerValue convertToInteger(ValueFactory valueFactory) {
137: return valueFactory.createIntegerValue();
138: }
139:
140: /**
141: * Converts this FloatValue to a LongValue.
142: */
143: public LongValue convertToLong(ValueFactory valueFactory) {
144: return valueFactory.createLongValue();
145: }
146:
147: /**
148: * Converts this FloatValue to a DoubleValue.
149: */
150: public DoubleValue convertToDouble(ValueFactory valueFactory) {
151: return valueFactory.createDoubleValue();
152: }
153:
154: // Similar binary methods, but this time with more specific arguments.
155:
156: /**
157: * Returns the generalization of this FloatValue and the given other
158: * SpecificFloatValue.
159: */
160: public FloatValue generalize(SpecificFloatValue other) {
161: return this ;
162: }
163:
164: /**
165: * Returns the sum of this FloatValue and the given SpecificFloatValue.
166: */
167: public FloatValue add(SpecificFloatValue other) {
168: return this ;
169: }
170:
171: /**
172: * Returns the difference of this FloatValue and the given SpecificFloatValue.
173: */
174: public FloatValue subtract(SpecificFloatValue other) {
175: return this ;
176: }
177:
178: /**
179: * Returns the difference of the given SpecificFloatValue and this FloatValue.
180: */
181: public FloatValue subtractFrom(SpecificFloatValue other) {
182: return this ;
183: }
184:
185: /**
186: * Returns the product of this FloatValue and the given SpecificFloatValue.
187: */
188: public FloatValue multiply(SpecificFloatValue other) {
189: return this ;
190: }
191:
192: /**
193: * Returns the quotient of this FloatValue and the given SpecificFloatValue.
194: */
195: public FloatValue divide(SpecificFloatValue other) {
196: return this ;
197: }
198:
199: /**
200: * Returns the quotient of the given SpecificFloatValue and this
201: * FloatValue.
202: */
203: public FloatValue divideOf(SpecificFloatValue other) {
204: return this ;
205: }
206:
207: /**
208: * Returns the remainder of this FloatValue divided by the given
209: * SpecificFloatValue.
210: */
211: public FloatValue remainder(SpecificFloatValue other) {
212: return this ;
213: }
214:
215: /**
216: * Returns the remainder of the given SpecificFloatValue and this
217: * FloatValue.
218: */
219: public FloatValue remainderOf(SpecificFloatValue other) {
220: return this ;
221: }
222:
223: /**
224: * Returns an IntegerValue with value -1, 0, or 1, if this FloatValue is
225: * less than, equal to, or greater than the given SpecificFloatValue,
226: * respectively.
227: */
228: public IntegerValue compare(SpecificFloatValue other,
229: ValueFactory valueFactory) {
230: return valueFactory.createIntegerValue();
231: }
232:
233: // Derived binary methods.
234:
235: /**
236: * Returns an IntegerValue with value 1, 0, or -1, if this FloatValue is
237: * less than, equal to, or greater than the given SpecificFloatValue,
238: * respectively.
239: */
240: public final IntegerValue compareReverse(SpecificFloatValue other,
241: ValueFactory valueFactory) {
242: return compare(other, valueFactory).negate();
243: }
244:
245: // Implementations for Value.
246:
247: public final FloatValue floatValue() {
248: return this ;
249: }
250:
251: public final Value generalize(Value other) {
252: return this .generalize(other.floatValue());
253: }
254:
255: public final int computationalType() {
256: return TYPE_FLOAT;
257: }
258:
259: public final String internalType() {
260: return String.valueOf(ClassConstants.INTERNAL_TYPE_FLOAT);
261: }
262:
263: // Implementations for Object.
264:
265: public boolean equals(Object object) {
266: return object != null && this .getClass() == object.getClass();
267: }
268:
269: public int hashCode() {
270: return this .getClass().hashCode();
271: }
272:
273: public String toString() {
274: return "f";
275: }
276: }
|