KickJava   Java API By Example, From Geeks To Geeks.

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


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 integer value.
27  *
28  * @author Eric Lafortune
29  */

30 public class IntegerValue extends Category1Value
31 {
32     /**
33      * Returns the specific integer value, if applicable.
34      */

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

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

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

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

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

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

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

89     public IntegerValue divide(IntegerValue other)
90     throws ArithmeticException JavaDoc
91     {
92         return this;
93     }
94
95     /**
96      * Returns the quotient of the given IntegerValue and this IntegerValue.
97      */

98     public IntegerValue divideOf(IntegerValue other)
99     throws ArithmeticException JavaDoc
100     {
101         return this;
102     }
103
104     /**
105      * Returns the remainder of this IntegerValue divided by the given
106      * IntegerValue.
107      */

108     public IntegerValue remainder(IntegerValue other)
109     throws ArithmeticException JavaDoc
110     {
111         return this;
112     }
113
114     /**
115      * Returns the remainder of the given IntegerValue divided by this
116      * IntegerValue.
117      */

118     public IntegerValue remainderOf(IntegerValue other)
119     throws ArithmeticException JavaDoc
120     {
121         return this;
122     }
123
124     /**
125      * Returns this IntegerValue, shifted left by the given IntegerValue.
126      */

127     public IntegerValue shiftLeft(IntegerValue other)
128     {
129         return this;
130     }
131
132     /**
133      * Returns the given IntegerValue, shifted left by this IntegerValue.
134      */

135     public IntegerValue shiftLeftOf(IntegerValue other)
136     {
137         return this;
138     }
139
140     /**
141      * Returns this IntegerValue, shifted right by the given IntegerValue.
142      */

143     public IntegerValue shiftRight(IntegerValue other)
144     {
145         return this;
146     }
147
148     /**
149      * Returns the given IntegerValue, shifted right by this IntegerValue.
150      */

151     public IntegerValue shiftRightOf(IntegerValue other)
152     {
153         return this;
154     }
155
156     /**
157      * Returns this unsigned IntegerValue, shifted left by the given
158      * IntegerValue.
159      */

160     public IntegerValue unsignedShiftRight(IntegerValue other)
161     {
162         return this;
163     }
164
165     /**
166      * Returns the given unsigned IntegerValue, shifted left by this
167      * IntegerValue.
168      */

169     public IntegerValue unsignedShiftRightOf(IntegerValue other)
170     {
171         return this;
172     }
173
174     /**
175      * Returns the given LongValue, shifted left by this IntegerValue.
176      */

177     public LongValue shiftLeftOf(LongValue other)
178     {
179         return ValueFactory.LONG_VALUE;
180     }
181
182     /**
183      * Returns the given LongValue, shifted right by this IntegerValue.
184      */

185     public LongValue shiftRightOf(LongValue other)
186     {
187         return ValueFactory.LONG_VALUE;
188     }
189
190     /**
191      * Returns the given unsigned LongValue, shifted right by this IntegerValue.
192      */

193     public LongValue unsignedShiftRightOf(LongValue other)
194     {
195         return ValueFactory.LONG_VALUE;
196     }
197
198     /**
199      * Returns the logical <i>and</i> of this IntegerValue and the given
200      * IntegerValue.
201      */

202     public IntegerValue and(IntegerValue other)
203     {
204         return this;
205     }
206
207     /**
208      * Returns the logical <i>or</i> of this IntegerValue and the given
209      * IntegerValue.
210      */

211     public IntegerValue or(IntegerValue other)
212     {
213         return this;
214     }
215
216     /**
217      * Returns the logical <i>xor</i> of this IntegerValue and the given
218      * IntegerValue.
219      */

220     public IntegerValue xor(IntegerValue other)
221     {
222         return this;
223     }
224
225     /**
226      * Returns whether this IntegerValue and the given IntegerValue are equal:
227      * <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
228      */

229     public int equal(IntegerValue other)
230     {
231         return MAYBE;
232     }
233
234     /**
235      * Returns whether this IntegerValue is less than the given IntegerValue:
236      * <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
237      */

238     public int lessThan(IntegerValue other)
239     {
240         return MAYBE;
241     }
242
243     /**
244      * Returns whether this IntegerValue is less than or equal to the given
245      * IntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
246      * <code>ALWAYS</code>.
247      */

248     public int lessThanOrEqual(IntegerValue other)
249     {
250         return MAYBE;
251     }
252
253
254     // Derived binary methods.
255

256     /**
257      * Returns whether this IntegerValue and the given IntegerValue are different:
258      * <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
259      */

260     public final int notEqual(IntegerValue other)
261     {
262         return -equal(other);
263     }
264
265     /**
266      * Returns whether this IntegerValue is greater than the given IntegerValue:
267      * <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
268      */

269     public final int greaterThan(IntegerValue other)
270     {
271         return -lessThanOrEqual(other);
272     }
273
274     /**
275      * Returns whether this IntegerValue is greater than or equal to the given IntegerValue:
276      * <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
277      */

278     public final int greaterThanOrEqual(IntegerValue other)
279     {
280         return -lessThan(other);
281     }
282
283
284     // Basic unary methods.
285

286     /**
287      * Returns the negated value of this IntegerValue.
288      */

289     public IntegerValue negate()
290     {
291         return this;
292     }
293
294     /**
295      * Converts this IntegerValue to a byte IntegerValue.
296      */

297     public IntegerValue convertToByte(ValueFactory valueFactory)
298     {
299         return this;
300     }
301
302     /**
303      * Converts this IntegerValue to a character IntegerValue.
304      */

305     public IntegerValue convertToCharacter(ValueFactory valueFactory)
306     {
307         return this;
308     }
309
310     /**
311      * Converts this IntegerValue to a short IntegerValue.
312      */

313     public IntegerValue convertToShort(ValueFactory valueFactory)
314     {
315         return this;
316     }
317
318     /**
319      * Converts this IntegerValue to a LongValue.
320      */

321     public LongValue convertToLong(ValueFactory valueFactory)
322     {
323         return valueFactory.createLongValue();
324     }
325
326     /**
327      * Converts this IntegerValue to a FloatValue.
328      */

329     public FloatValue convertToFloat(ValueFactory valueFactory)
330     {
331         return valueFactory.createFloatValue();
332     }
333
334     /**
335      * Converts this IntegerValue to a DoubleValue.
336      */

337     public DoubleValue convertToDouble(ValueFactory valueFactory)
338     {
339         return valueFactory.createDoubleValue();
340     }
341
342
343     // Similar binary methods, but this time with more specific arguments.
344

345     /**
346      * Returns the generalization of this IntegerValue and the given other
347      * SpecificIntegerValue.
348      */

349     public IntegerValue generalize(SpecificIntegerValue other)
350     {
351         return this;
352     }
353
354
355     /**
356      * Returns the sum of this IntegerValue and the given SpecificIntegerValue.
357      */

358     public IntegerValue add(SpecificIntegerValue other)
359     {
360         return this;
361     }
362
363     /**
364      * Returns the difference of this IntegerValue and the given SpecificIntegerValue.
365      */

366     public IntegerValue subtract(SpecificIntegerValue other)
367     {
368         return this;
369     }
370
371     /**
372      * Returns the difference of the given SpecificIntegerValue and this IntegerValue.
373      */

374     public IntegerValue subtractFrom(SpecificIntegerValue other)
375     {
376         return this;
377     }
378
379     /**
380      * Returns the product of this IntegerValue and the given SpecificIntegerValue.
381      */

382     public IntegerValue multiply(SpecificIntegerValue other)
383     {
384         return this;
385     }
386
387     /**
388      * Returns the quotient of this IntegerValue and the given
389      * SpecificIntegerValue.
390      */

391     public IntegerValue divide(SpecificIntegerValue other)
392     {
393         return this;
394     }
395
396     /**
397      * Returns the quotient of the given SpecificIntegerValue and this
398      * IntegerValue.
399      */

400     public IntegerValue divideOf(SpecificIntegerValue other)
401     {
402         return this;
403     }
404
405     /**
406      * Returns the remainder of this IntegerValue divided by the given
407      * SpecificIntegerValue.
408      */

409     public IntegerValue remainder(SpecificIntegerValue other)
410     {
411         return this;
412     }
413
414     /**
415      * Returns the remainder of the given SpecificIntegerValue divided by this
416      * IntegerValue.
417      */

418     public IntegerValue remainderOf(SpecificIntegerValue other)
419     {
420         return this;
421     }
422
423     /**
424      * Returns this IntegerValue, shifted left by the given SpecificIntegerValue.
425      */

426     public IntegerValue shiftLeft(SpecificIntegerValue other)
427     {
428         return this;
429     }
430
431     /**
432      * Returns the given SpecificIntegerValue, shifted left by this IntegerValue.
433      */

434     public IntegerValue shiftLeftOf(SpecificIntegerValue other)
435     {
436         return this;
437     }
438
439     /**
440      * Returns this IntegerValue, shifted right by the given SpecificIntegerValue.
441      */

442     public IntegerValue shiftRight(SpecificIntegerValue other)
443     {
444         return this;
445     }
446
447     /**
448      * Returns the given SpecificIntegerValue, shifted right by this IntegerValue.
449      */

450     public IntegerValue shiftRightOf(SpecificIntegerValue other)
451     {
452         return this;
453     }
454
455     /**
456      * Returns this unsigned IntegerValue, shifted right by the given
457      * SpecificIntegerValue.
458      */

459     public IntegerValue unsignedShiftRight(SpecificIntegerValue other)
460     {
461         return this;
462     }
463
464     /**
465      * Returns the given unsigned SpecificIntegerValue, shifted right by this
466      * IntegerValue.
467      */

468     public IntegerValue unsignedShiftRightOf(SpecificIntegerValue other)
469     {
470         return this;
471     }
472
473     /**
474      * Returns the given SpecificLongValue, shifted left by this IntegerValue.
475      */

476     public LongValue shiftLeftOf(SpecificLongValue other)
477     {
478         return ValueFactory.LONG_VALUE;
479     }
480
481     /**
482      * Returns the given SpecificLongValue, shifted right by this IntegerValue.
483      */

484     public LongValue shiftRightOf(SpecificLongValue other)
485     {
486         return ValueFactory.LONG_VALUE;
487     }
488
489     /**
490      * Returns the given unsigned SpecificLongValue, shifted right by this
491      * IntegerValue.
492      */

493     public LongValue unsignedShiftRightOf(SpecificLongValue other)
494     {
495         return ValueFactory.LONG_VALUE;
496     }
497
498     /**
499      * Returns the logical <i>and</i> of this IntegerValue and the given
500      * SpecificIntegerValue.
501      */

502     public IntegerValue and(SpecificIntegerValue other)
503     {
504         return this;
505     }
506
507     /**
508      * Returns the logical <i>or</i> of this IntegerValue and the given
509      * SpecificIntegerValue.
510      */

511     public IntegerValue or(SpecificIntegerValue other)
512     {
513         return this;
514     }
515
516     /**
517      * Returns the logical <i>xor</i> of this IntegerValue and the given
518      * SpecificIntegerValue.
519      */

520     public IntegerValue xor(SpecificIntegerValue other)
521     {
522         return this;
523     }
524
525     /**
526      * Returns whether this IntegerValue and the given SpecificIntegerValue are
527      * equal: <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
528      */

529     public int equal(SpecificIntegerValue other)
530     {
531         return MAYBE;
532     }
533
534     /**
535      * Returns whether this IntegerValue is less than the given
536      * SpecificIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
537      * <code>ALWAYS</code>.
538      */

539     public int lessThan(SpecificIntegerValue other)
540     {
541         return MAYBE;
542     }
543
544     /**
545      * Returns whether this IntegerValue is less than or equal to the given
546      * SpecificIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
547      * <code>ALWAYS</code>.
548      */

549     public int lessThanOrEqual(SpecificIntegerValue other)
550     {
551         return MAYBE;
552     }
553
554
555     // Derived binary methods.
556

557     /**
558      * Returns whether this IntegerValue and the given SpecificIntegerValue are
559      * different: <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
560      */

561     public final int notEqual(SpecificIntegerValue other)
562     {
563         return -equal(other);
564     }
565
566     /**
567      * Returns whether this IntegerValue is greater than the given
568      * SpecificIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
569      * <code>ALWAYS</code>.
570      */

571     public final int greaterThan(SpecificIntegerValue other)
572     {
573         return -lessThanOrEqual(other);
574     }
575
576     /**
577      * Returns whether this IntegerValue is greater than or equal to the given
578      * SpecificIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
579      * <code>ALWAYS</code>.
580      */

581     public final int greaterThanOrEqual(SpecificIntegerValue other)
582     {
583         return -lessThan(other);
584     }
585
586
587     // Implementations for Value.
588

589     public final IntegerValue integerValue()
590     {
591         return this;
592     }
593
594     public final Value generalize(Value other)
595     {
596         return this.generalize(other.integerValue());
597     }
598
599     public final int computationalType()
600     {
601         return TYPE_INTEGER;
602     }
603
604     public final String JavaDoc internalType()
605     {
606         return "" + ClassConstants.INTERNAL_TYPE_INT;
607     }
608
609
610     // Implementations for Object.
611

612     public boolean equals(Object JavaDoc object)
613     {
614         return object != null &&
615                this.getClass() == object.getClass();
616     }
617
618
619     public int hashCode()
620     {
621         return this.getClass().hashCode();
622     }
623
624
625     public String JavaDoc toString()
626     {
627         return "i";
628     }
629 }
630
Popular Tags