KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
24  * This abstract class represents a partially evaluated value.
25  *
26  * @author Eric Lafortune
27  */

28 public abstract class Value
29 {
30     public static final int NEVER = -1;
31     public static final int MAYBE = 0;
32     public static final int ALWAYS = 1;
33
34     public static final int TYPE_INTEGER = 1;
35     public static final int TYPE_LONG = 2;
36     public static final int TYPE_FLOAT = 3;
37     public static final int TYPE_DOUBLE = 4;
38     public static final int TYPE_REFERENCE = 5;
39     public static final int TYPE_INSTRUCTION_OFFSET = 6;
40     public static final int TYPE_TOP = 7;
41
42
43     /**
44      * Returns this Value as a Category1Value.
45      */

46     public Category1Value category1Value()
47     {
48         throw new IllegalArgumentException JavaDoc("Value is not a Category 1 value [" + this.getClass().getName() + "]");
49     }
50
51     /**
52      * Returns this Value as a Category2Value.
53      */

54     public Category2Value category2Value()
55     {
56         throw new IllegalArgumentException JavaDoc("Value is not a Category 2 value [" + this.getClass().getName() + "]");
57     }
58
59
60     /**
61      * Returns this Value as an IntegerValue.
62      */

63     public IntegerValue integerValue()
64     {
65         throw new IllegalArgumentException JavaDoc("Value is not an integer value [" + this.getClass().getName() + "]");
66     }
67
68     /**
69      * Returns this Value as a LongValue.
70      */

71     public LongValue longValue()
72     {
73         throw new IllegalArgumentException JavaDoc("Value is not a long value [" + this.getClass().getName() + "]");
74     }
75
76     /**
77      * Returns this Value as a FloatValue.
78      */

79     public FloatValue floatValue()
80     {
81         throw new IllegalArgumentException JavaDoc("Value is not a float value [" + this.getClass().getName() + "]");
82     }
83
84     /**
85      * Returns this Value as a DoubleValue.
86      */

87     public DoubleValue doubleValue()
88     {
89         throw new IllegalArgumentException JavaDoc("Value is not a double value [" + this.getClass().getName() + "]");
90     }
91
92     /**
93      * Returns this Value as a ReferenceValue.
94      */

95     public ReferenceValue referenceValue()
96     {
97         throw new IllegalArgumentException JavaDoc("Value is not a reference value [" + this.getClass().getName() + "]");
98     }
99
100     /**
101      * Returns this Value as a InstructionOffsetValue.
102      */

103     public InstructionOffsetValue instructionOffsetValue()
104     {
105         throw new IllegalArgumentException JavaDoc("Value is not an instruction offset value [" + this.getClass().getName() + "]");
106     }
107
108
109     /**
110      * Returns whether this Value represents a single specific value.
111      */

112     public boolean isSpecific()
113     {
114         return false;
115     }
116
117
118     /**
119      * Returns the generalization of this Value and the given other Value.
120      */

121     public abstract Value generalize(Value other);
122
123
124     /**
125      * Returns whether the computational type of this Value is a category 2 type.
126      * This means that it takes up the space of two category 1 types on the
127      * stack, for instance.
128      */

129     public abstract boolean isCategory2();
130
131
132     /**
133      * Returns the computational type of this Value.
134      * @return <code>TYPE_INTEGER</code>,
135      * <code>TYPE_LONG</code>,
136      * <code>TYPE_FLOAT</code>,
137      * <code>TYPE_DOUBLE</code>,
138      * <code>TYPE_REFERENCE</code>, or
139      * <code>TYPE_INSTRUCTION_OFFSET</code>.
140      */

141     public abstract int computationalType();
142
143
144     /**
145      * Returns the internal type of this Value.
146      * @return <code>ClassConstants.INTERNAL_TYPE_BOOLEAN</code>,
147      * <code>ClassConstants.INTERNAL_TYPE_BYTE</code>,
148      * <code>ClassConstants.INTERNAL_TYPE_CHAR</code>,
149      * <code>ClassConstants.INTERNAL_TYPE_SHORT</code>,
150      * <code>ClassConstants.INTERNAL_TYPE_INT</code>,
151      * <code>ClassConstants.INTERNAL_TYPE_LONG</code>,
152      * <code>ClassConstants.INTERNAL_TYPE_FLOAT</code>,
153      * <code>ClassConstants.INTERNAL_TYPE_DOUBLE</code>,
154      * <code>ClassConstants.INTERNAL_TYPE_CLASS_START ... ClassConstants.INTERNAL_TYPE_CLASS_END</code>, or
155      * an array type containing any of these types (always as String).
156      */

157     public abstract String JavaDoc internalType();
158 }
159
Popular Tags