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 integer value.
027: *
028: * @author Eric Lafortune
029: */
030: public class IntegerValue extends Category1Value {
031: /**
032: * Returns the specific integer value, if applicable.
033: */
034: public int value() {
035: return 0;
036: }
037:
038: // Basic binary methods.
039:
040: /**
041: * Returns the generalization of this IntegerValue and the given other
042: * IntegerValue.
043: */
044: public IntegerValue generalize(IntegerValue other) {
045: return this ;
046: }
047:
048: /**
049: * Returns the sum of this IntegerValue and the given IntegerValue.
050: */
051: public IntegerValue add(IntegerValue other) {
052: return this ;
053: }
054:
055: /**
056: * Returns the difference of this IntegerValue and the given IntegerValue.
057: */
058: public IntegerValue subtract(IntegerValue other) {
059: return this ;
060: }
061:
062: /**
063: * Returns the difference of the given IntegerValue and this IntegerValue.
064: */
065: public IntegerValue subtractFrom(IntegerValue other) {
066: return this ;
067: }
068:
069: /**
070: * Returns the product of this IntegerValue and the given IntegerValue.
071: */
072: public IntegerValue multiply(IntegerValue other)
073: throws ArithmeticException {
074: return this ;
075: }
076:
077: /**
078: * Returns the quotient of this IntegerValue and the given IntegerValue.
079: */
080: public IntegerValue divide(IntegerValue other)
081: throws ArithmeticException {
082: return this ;
083: }
084:
085: /**
086: * Returns the quotient of the given IntegerValue and this IntegerValue.
087: */
088: public IntegerValue divideOf(IntegerValue other)
089: throws ArithmeticException {
090: return this ;
091: }
092:
093: /**
094: * Returns the remainder of this IntegerValue divided by the given
095: * IntegerValue.
096: */
097: public IntegerValue remainder(IntegerValue other)
098: throws ArithmeticException {
099: return this ;
100: }
101:
102: /**
103: * Returns the remainder of the given IntegerValue divided by this
104: * IntegerValue.
105: */
106: public IntegerValue remainderOf(IntegerValue other)
107: throws ArithmeticException {
108: return this ;
109: }
110:
111: /**
112: * Returns this IntegerValue, shifted left by the given IntegerValue.
113: */
114: public IntegerValue shiftLeft(IntegerValue other) {
115: return this ;
116: }
117:
118: /**
119: * Returns the given IntegerValue, shifted left by this IntegerValue.
120: */
121: public IntegerValue shiftLeftOf(IntegerValue other) {
122: return this ;
123: }
124:
125: /**
126: * Returns this IntegerValue, shifted right by the given IntegerValue.
127: */
128: public IntegerValue shiftRight(IntegerValue other) {
129: return this ;
130: }
131:
132: /**
133: * Returns the given IntegerValue, shifted right by this IntegerValue.
134: */
135: public IntegerValue shiftRightOf(IntegerValue other) {
136: return this ;
137: }
138:
139: /**
140: * Returns this unsigned IntegerValue, shifted left by the given
141: * IntegerValue.
142: */
143: public IntegerValue unsignedShiftRight(IntegerValue other) {
144: return this ;
145: }
146:
147: /**
148: * Returns the given unsigned IntegerValue, shifted left by this
149: * IntegerValue.
150: */
151: public IntegerValue unsignedShiftRightOf(IntegerValue other) {
152: return this ;
153: }
154:
155: /**
156: * Returns the given LongValue, shifted left by this IntegerValue.
157: */
158: public LongValue shiftLeftOf(LongValue other) {
159: return ValueFactory.LONG_VALUE;
160: }
161:
162: /**
163: * Returns the given LongValue, shifted right by this IntegerValue.
164: */
165: public LongValue shiftRightOf(LongValue other) {
166: return ValueFactory.LONG_VALUE;
167: }
168:
169: /**
170: * Returns the given unsigned LongValue, shifted right by this IntegerValue.
171: */
172: public LongValue unsignedShiftRightOf(LongValue other) {
173: return ValueFactory.LONG_VALUE;
174: }
175:
176: /**
177: * Returns the logical <i>and</i> of this IntegerValue and the given
178: * IntegerValue.
179: */
180: public IntegerValue and(IntegerValue other) {
181: return this ;
182: }
183:
184: /**
185: * Returns the logical <i>or</i> of this IntegerValue and the given
186: * IntegerValue.
187: */
188: public IntegerValue or(IntegerValue other) {
189: return this ;
190: }
191:
192: /**
193: * Returns the logical <i>xor</i> of this IntegerValue and the given
194: * IntegerValue.
195: */
196: public IntegerValue xor(IntegerValue other) {
197: return this ;
198: }
199:
200: /**
201: * Returns whether this IntegerValue and the given IntegerValue are equal:
202: * <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
203: */
204: public int equal(IntegerValue other) {
205: return MAYBE;
206: }
207:
208: /**
209: * Returns whether this IntegerValue is less than the given IntegerValue:
210: * <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
211: */
212: public int lessThan(IntegerValue other) {
213: return MAYBE;
214: }
215:
216: /**
217: * Returns whether this IntegerValue is less than or equal to the given
218: * IntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
219: * <code>ALWAYS</code>.
220: */
221: public int lessThanOrEqual(IntegerValue other) {
222: return MAYBE;
223: }
224:
225: // Derived binary methods.
226:
227: /**
228: * Returns whether this IntegerValue and the given IntegerValue are different:
229: * <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
230: */
231: public final int notEqual(IntegerValue other) {
232: return -equal(other);
233: }
234:
235: /**
236: * Returns whether this IntegerValue is greater than the given IntegerValue:
237: * <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
238: */
239: public final int greaterThan(IntegerValue other) {
240: return -lessThanOrEqual(other);
241: }
242:
243: /**
244: * Returns whether this IntegerValue is greater than or equal to the given IntegerValue:
245: * <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
246: */
247: public final int greaterThanOrEqual(IntegerValue other) {
248: return -lessThan(other);
249: }
250:
251: // Basic unary methods.
252:
253: /**
254: * Returns the negated value of this IntegerValue.
255: */
256: public IntegerValue negate() {
257: return this ;
258: }
259:
260: /**
261: * Converts this IntegerValue to a byte IntegerValue.
262: */
263: public IntegerValue convertToByte(ValueFactory valueFactory) {
264: return this ;
265: }
266:
267: /**
268: * Converts this IntegerValue to a character IntegerValue.
269: */
270: public IntegerValue convertToCharacter(ValueFactory valueFactory) {
271: return this ;
272: }
273:
274: /**
275: * Converts this IntegerValue to a short IntegerValue.
276: */
277: public IntegerValue convertToShort(ValueFactory valueFactory) {
278: return this ;
279: }
280:
281: /**
282: * Converts this IntegerValue to a LongValue.
283: */
284: public LongValue convertToLong(ValueFactory valueFactory) {
285: return valueFactory.createLongValue();
286: }
287:
288: /**
289: * Converts this IntegerValue to a FloatValue.
290: */
291: public FloatValue convertToFloat(ValueFactory valueFactory) {
292: return valueFactory.createFloatValue();
293: }
294:
295: /**
296: * Converts this IntegerValue to a DoubleValue.
297: */
298: public DoubleValue convertToDouble(ValueFactory valueFactory) {
299: return valueFactory.createDoubleValue();
300: }
301:
302: // Similar binary methods, but this time with more specific arguments.
303:
304: /**
305: * Returns the generalization of this IntegerValue and the given other
306: * SpecificIntegerValue.
307: */
308: public IntegerValue generalize(SpecificIntegerValue other) {
309: return this ;
310: }
311:
312: /**
313: * Returns the sum of this IntegerValue and the given SpecificIntegerValue.
314: */
315: public IntegerValue add(SpecificIntegerValue other) {
316: return this ;
317: }
318:
319: /**
320: * Returns the difference of this IntegerValue and the given SpecificIntegerValue.
321: */
322: public IntegerValue subtract(SpecificIntegerValue other) {
323: return this ;
324: }
325:
326: /**
327: * Returns the difference of the given SpecificIntegerValue and this IntegerValue.
328: */
329: public IntegerValue subtractFrom(SpecificIntegerValue other) {
330: return this ;
331: }
332:
333: /**
334: * Returns the product of this IntegerValue and the given SpecificIntegerValue.
335: */
336: public IntegerValue multiply(SpecificIntegerValue other) {
337: return this ;
338: }
339:
340: /**
341: * Returns the quotient of this IntegerValue and the given
342: * SpecificIntegerValue.
343: */
344: public IntegerValue divide(SpecificIntegerValue other) {
345: return this ;
346: }
347:
348: /**
349: * Returns the quotient of the given SpecificIntegerValue and this
350: * IntegerValue.
351: */
352: public IntegerValue divideOf(SpecificIntegerValue other) {
353: return this ;
354: }
355:
356: /**
357: * Returns the remainder of this IntegerValue divided by the given
358: * SpecificIntegerValue.
359: */
360: public IntegerValue remainder(SpecificIntegerValue other) {
361: return this ;
362: }
363:
364: /**
365: * Returns the remainder of the given SpecificIntegerValue divided by this
366: * IntegerValue.
367: */
368: public IntegerValue remainderOf(SpecificIntegerValue other) {
369: return this ;
370: }
371:
372: /**
373: * Returns this IntegerValue, shifted left by the given SpecificIntegerValue.
374: */
375: public IntegerValue shiftLeft(SpecificIntegerValue other) {
376: return this ;
377: }
378:
379: /**
380: * Returns the given SpecificIntegerValue, shifted left by this IntegerValue.
381: */
382: public IntegerValue shiftLeftOf(SpecificIntegerValue other) {
383: return this ;
384: }
385:
386: /**
387: * Returns this IntegerValue, shifted right by the given SpecificIntegerValue.
388: */
389: public IntegerValue shiftRight(SpecificIntegerValue other) {
390: return this ;
391: }
392:
393: /**
394: * Returns the given SpecificIntegerValue, shifted right by this IntegerValue.
395: */
396: public IntegerValue shiftRightOf(SpecificIntegerValue other) {
397: return this ;
398: }
399:
400: /**
401: * Returns this unsigned IntegerValue, shifted right by the given
402: * SpecificIntegerValue.
403: */
404: public IntegerValue unsignedShiftRight(SpecificIntegerValue other) {
405: return this ;
406: }
407:
408: /**
409: * Returns the given unsigned SpecificIntegerValue, shifted right by this
410: * IntegerValue.
411: */
412: public IntegerValue unsignedShiftRightOf(SpecificIntegerValue other) {
413: return this ;
414: }
415:
416: /**
417: * Returns the given SpecificLongValue, shifted left by this IntegerValue.
418: */
419: public LongValue shiftLeftOf(SpecificLongValue other) {
420: return ValueFactory.LONG_VALUE;
421: }
422:
423: /**
424: * Returns the given SpecificLongValue, shifted right by this IntegerValue.
425: */
426: public LongValue shiftRightOf(SpecificLongValue other) {
427: return ValueFactory.LONG_VALUE;
428: }
429:
430: /**
431: * Returns the given unsigned SpecificLongValue, shifted right by this
432: * IntegerValue.
433: */
434: public LongValue unsignedShiftRightOf(SpecificLongValue other) {
435: return ValueFactory.LONG_VALUE;
436: }
437:
438: /**
439: * Returns the logical <i>and</i> of this IntegerValue and the given
440: * SpecificIntegerValue.
441: */
442: public IntegerValue and(SpecificIntegerValue other) {
443: return this ;
444: }
445:
446: /**
447: * Returns the logical <i>or</i> of this IntegerValue and the given
448: * SpecificIntegerValue.
449: */
450: public IntegerValue or(SpecificIntegerValue other) {
451: return this ;
452: }
453:
454: /**
455: * Returns the logical <i>xor</i> of this IntegerValue and the given
456: * SpecificIntegerValue.
457: */
458: public IntegerValue xor(SpecificIntegerValue other) {
459: return this ;
460: }
461:
462: /**
463: * Returns whether this IntegerValue and the given SpecificIntegerValue are
464: * equal: <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
465: */
466: public int equal(SpecificIntegerValue other) {
467: return MAYBE;
468: }
469:
470: /**
471: * Returns whether this IntegerValue is less than the given
472: * SpecificIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
473: * <code>ALWAYS</code>.
474: */
475: public int lessThan(SpecificIntegerValue other) {
476: return MAYBE;
477: }
478:
479: /**
480: * Returns whether this IntegerValue is less than or equal to the given
481: * SpecificIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
482: * <code>ALWAYS</code>.
483: */
484: public int lessThanOrEqual(SpecificIntegerValue other) {
485: return MAYBE;
486: }
487:
488: // Derived binary methods.
489:
490: /**
491: * Returns whether this IntegerValue and the given SpecificIntegerValue are
492: * different: <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
493: */
494: public final int notEqual(SpecificIntegerValue other) {
495: return -equal(other);
496: }
497:
498: /**
499: * Returns whether this IntegerValue is greater than the given
500: * SpecificIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
501: * <code>ALWAYS</code>.
502: */
503: public final int greaterThan(SpecificIntegerValue other) {
504: return -lessThanOrEqual(other);
505: }
506:
507: /**
508: * Returns whether this IntegerValue is greater than or equal to the given
509: * SpecificIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
510: * <code>ALWAYS</code>.
511: */
512: public final int greaterThanOrEqual(SpecificIntegerValue other) {
513: return -lessThan(other);
514: }
515:
516: // Implementations for Value.
517:
518: public final IntegerValue integerValue() {
519: return this ;
520: }
521:
522: public final Value generalize(Value other) {
523: return this .generalize(other.integerValue());
524: }
525:
526: public final int computationalType() {
527: return TYPE_INTEGER;
528: }
529:
530: public final String internalType() {
531: return String.valueOf(ClassConstants.INTERNAL_TYPE_INT);
532: }
533:
534: // Implementations for Object.
535:
536: public boolean equals(Object object) {
537: return object != null && this .getClass() == object.getClass();
538: }
539:
540: public int hashCode() {
541: return this .getClass().hashCode();
542: }
543:
544: public String toString() {
545: return "i";
546: }
547: }
|