KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > proguard > evaluation > value > DoubleValue


1 /*
2  * ProGuard -- shrinking, optimization, obfuscation, and preverification
3  * of Java bytecode.
4  *
5  * Copyright (c) 2002-2007 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  */

21 package proguard.evaluation.value;
22
23 import proguard.classfile.ClassConstants;
24
25 /**
26  * This class represents a partially evaluated double value.
27  *
28  * @author Eric Lafortune
29  */

30 public class DoubleValue extends Category2Value
31 {
32     /**
33      * Returns the specific double value, if applicable.
34      */

35     public double value()
36     {
37         return 0.0;
38     }
39
40
41     // Basic binary methods.
42

43     /**
44      * Returns the generalization of this DoubleValue and the given other
45      * DoubleValue.
46      */

47     public DoubleValue generalize(DoubleValue other)
48     {
49         return this;
50     }
51
52
53     /**
54      * Returns the sum of this DoubleValue and the given DoubleValue.
55      */

56     public DoubleValue add(DoubleValue other)
57     {
58         return this;
59     }
60
61     /**
62      * Returns the difference of this DoubleValue and the given DoubleValue.
63      */

64     public DoubleValue subtract(DoubleValue other)
65     {
66         return this;
67     }
68
69     /**
70      * Returns the difference of the given DoubleValue and this DoubleValue.
71      */

72     public DoubleValue subtractFrom(DoubleValue other)
73     {
74         return this;
75     }
76
77     /**
78      * Returns the product of this DoubleValue and the given DoubleValue.
79      */

80     public DoubleValue multiply(DoubleValue other)
81     {
82         return this;
83     }
84
85     /**
86      * Returns the quotient of this DoubleValue and the given DoubleValue.
87      */

88     public DoubleValue divide(DoubleValue other)
89     {
90         return this;
91     }
92
93     /**
94      * Returns the quotient of the given DoubleValue and this DoubleValue.
95      */

96     public DoubleValue divideOf(DoubleValue other)
97     {
98         return this;
99     }
100
101     /**
102      * Returns the remainder of this DoubleValue divided by the given DoubleValue.
103      */

104     public DoubleValue remainder(DoubleValue other)
105     {
106         return this;
107     }
108
109     /**
110      * Returns the remainder of the given DoubleValue divided by this DoubleValue.
111      */

112     public DoubleValue remainderOf(DoubleValue other)
113     {
114         return this;
115     }
116
117     /**
118      * Returns an IntegerValue with value -1, 0, or 1, if this DoubleValue is
119      * less than, equal to, or greater than the given DoubleValue, respectively.
120      */

121     public IntegerValue compare(DoubleValue other, ValueFactory valueFactory)
122     {
123         return valueFactory.createIntegerValue();
124     }
125
126
127     // Derived binary methods.
128

129     /**
130      * Returns an IntegerValue with value 1, 0, or -1, if this DoubleValue is
131      * less than, equal to, or greater than the given DoubleValue, respectively.
132      */

133     public final IntegerValue compareReverse(DoubleValue other, ValueFactory valueFactory)
134     {
135         return compare(other, valueFactory).negate();
136     }
137
138
139     // Basic unary methods.
140

141     /**
142      * Returns the negated value of this DoubleValue.
143      */

144     public DoubleValue negate()
145     {
146         return this;
147     }
148
149     /**
150      * Converts this DoubleValue to an IntegerValue.
151      */

152     public IntegerValue convertToInteger(ValueFactory valueFactory)
153     {
154         return valueFactory.createIntegerValue();
155     }
156
157     /**
158      * Converts this DoubleValue to a LongValue.
159      */

160     public LongValue convertToLong(ValueFactory valueFactory)
161     {
162         return valueFactory.createLongValue();
163     }
164
165     /**
166      * Converts this DoubleValue to a FloatValue.
167      */

168     public FloatValue convertToFloat(ValueFactory valueFactory)
169     {
170         return valueFactory.createFloatValue();
171     }
172
173
174     // Similar binary methods, but this time with more specific arguments.
175

176     /**
177      * Returns the generalization of this DoubleValue and the given other
178      * SpecificDoubleValue.
179      */

180     public DoubleValue generalize(SpecificDoubleValue other)
181     {
182         return this;
183     }
184
185
186     /**
187      * Returns the sum of this DoubleValue and the given SpecificDoubleValue.
188      */

189     public DoubleValue add(SpecificDoubleValue other)
190     {
191         return this;
192     }
193
194     /**
195      * Returns the difference of this DoubleValue and the given SpecificDoubleValue.
196      */

197     public DoubleValue subtract(SpecificDoubleValue other)
198     {
199         return this;
200     }
201
202     /**
203      * Returns the difference of the given SpecificDoubleValue and this DoubleValue.
204      */

205     public DoubleValue subtractFrom(SpecificDoubleValue other)
206     {
207         return this;
208     }
209
210     /**
211      * Returns the product of this DoubleValue and the given SpecificDoubleValue.
212      */

213     public DoubleValue multiply(SpecificDoubleValue other)
214     {
215         return this;
216     }
217
218     /**
219      * Returns the quotient of this DoubleValue and the given SpecificDoubleValue.
220      */

221     public DoubleValue divide(SpecificDoubleValue other)
222     {
223         return this;
224     }
225
226     /**
227      * Returns the quotient of the given SpecificDoubleValue and this
228      * DoubleValue.
229      */

230     public DoubleValue divideOf(SpecificDoubleValue other)
231     {
232         return this;
233     }
234
235     /**
236      * Returns the remainder of this DoubleValue divided by the given
237      * SpecificDoubleValue.
238      */

239     public DoubleValue remainder(SpecificDoubleValue other)
240     {
241         return this;
242     }
243
244     /**
245      * Returns the remainder of the given SpecificDoubleValue and this
246      * DoubleValue.
247      */

248     public DoubleValue remainderOf(SpecificDoubleValue other)
249     {
250         return this;
251     }
252
253     /**
254      * Returns an IntegerValue with value -1, 0, or 1, if this DoubleValue is
255      * less than, equal to, or greater than the given SpecificDoubleValue,
256      * respectively.
257      */

258     public IntegerValue compare(SpecificDoubleValue other, ValueFactory valueFactory)
259     {
260         return valueFactory.createIntegerValue();
261     }
262
263
264     // Derived binary methods.
265

266     /**
267      * Returns an IntegerValue with value 1, 0, or -1, if this DoubleValue is
268      * less than, equal to, or greater than the given SpecificDoubleValue,
269      * respectively.
270      */

271     public final IntegerValue compareReverse(SpecificDoubleValue other, ValueFactory valueFactory)
272     {
273         return compare(other, valueFactory).negate();
274     }
275
276
277     // Implementations for Value.
278

279     public final DoubleValue doubleValue()
280     {
281         return this;
282     }
283
284     public final Value generalize(Value other)
285     {
286         return this.generalize(other.doubleValue());
287     }
288
289     public final int computationalType()
290     {
291         return TYPE_DOUBLE;
292     }
293
294     public final String JavaDoc internalType()
295     {
296         return "" + ClassConstants.INTERNAL_TYPE_DOUBLE;
297     }
298
299
300     // Implementations for Object.
301

302     public boolean equals(Object JavaDoc object)
303     {
304         return object != null &&
305                this.getClass() == object.getClass();
306     }
307
308
309     public int hashCode()
310     {
311         return this.getClass().hashCode();
312     }
313
314
315     public String JavaDoc toString()
316     {
317         return "d";
318     }
319 }
320
Popular Tags