• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * ProGuard -- shrinking, optimization, obfuscation, and preverification
3  *             of Java bytecode.
4  *
5  * Copyright (c) 2002-2014 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 DoubleValue represents a specific double value.
25  *
26  * @author Eric Lafortune
27  */
28 abstract class SpecificDoubleValue extends DoubleValue
29 {
30     // Implementations of unary methods of DoubleValue.
31 
negate()32     public DoubleValue negate()
33     {
34         return new NegatedDoubleValue(this);
35     }
36 
convertToInteger()37     public IntegerValue convertToInteger()
38     {
39         return new ConvertedIntegerValue(this);
40     }
41 
convertToLong()42     public LongValue convertToLong()
43     {
44         return new ConvertedLongValue(this);
45     }
46 
convertToFloat()47     public FloatValue convertToFloat()
48     {
49         return new ConvertedFloatValue(this);
50     }
51 
52 
53     // Implementations of binary methods of DoubleValue.
54 
generalize(DoubleValue other)55     public DoubleValue generalize(DoubleValue other)
56     {
57         return other.generalize(this);
58     }
59 
add(DoubleValue other)60     public DoubleValue add(DoubleValue other)
61     {
62         return other.add(this);
63     }
64 
subtract(DoubleValue other)65     public DoubleValue subtract(DoubleValue other)
66     {
67         return other.subtractFrom(this);
68     }
69 
subtractFrom(DoubleValue other)70     public DoubleValue subtractFrom(DoubleValue other)
71     {
72         return other.subtract(this);
73     }
74 
multiply(DoubleValue other)75     public DoubleValue multiply(DoubleValue other)
76     {
77         return other.multiply(this);
78     }
79 
divide(DoubleValue other)80     public DoubleValue divide(DoubleValue other)
81     {
82         return other.divideOf(this);
83     }
84 
divideOf(DoubleValue other)85     public DoubleValue divideOf(DoubleValue other)
86     {
87         return other.divide(this);
88     }
89 
remainder(DoubleValue other)90     public DoubleValue remainder(DoubleValue other)
91     {
92         return other.remainderOf(this);
93     }
94 
remainderOf(DoubleValue other)95     public DoubleValue remainderOf(DoubleValue other)
96     {
97         return other.remainder(this);
98     }
99 
compare(DoubleValue other)100     public IntegerValue compare(DoubleValue other)
101     {
102         return other.compareReverse(this);
103     }
104 
105 
106     // Implementations of binary DoubleValue methods with SpecificDoubleValue
107     // arguments.
108 
generalize(SpecificDoubleValue other)109     public DoubleValue generalize(SpecificDoubleValue other)
110     {
111         return this.equals(other) ? this : ValueFactory.DOUBLE_VALUE;
112     }
113 
add(SpecificDoubleValue other)114     public DoubleValue add(SpecificDoubleValue other)
115     {
116         return new CompositeDoubleValue(this, CompositeDoubleValue.ADD, other);
117     }
118 
subtract(SpecificDoubleValue other)119     public DoubleValue subtract(SpecificDoubleValue other)
120     {
121         return new CompositeDoubleValue(this, CompositeDoubleValue.SUBTRACT, other);
122     }
123 
subtractFrom(SpecificDoubleValue other)124     public DoubleValue subtractFrom(SpecificDoubleValue other)
125     {
126         return new CompositeDoubleValue(other, CompositeDoubleValue.SUBTRACT, this);
127     }
128 
multiply(SpecificDoubleValue other)129     public DoubleValue multiply(SpecificDoubleValue other)
130     {
131         return new CompositeDoubleValue(this, CompositeDoubleValue.MULTIPLY, other);
132     }
133 
divide(SpecificDoubleValue other)134     public DoubleValue divide(SpecificDoubleValue other)
135     {
136         return new CompositeDoubleValue(this, CompositeDoubleValue.DIVIDE, other);
137     }
138 
divideOf(SpecificDoubleValue other)139     public DoubleValue divideOf(SpecificDoubleValue other)
140     {
141         return new CompositeDoubleValue(other, CompositeDoubleValue.DIVIDE, this);
142     }
143 
remainder(SpecificDoubleValue other)144     public DoubleValue remainder(SpecificDoubleValue other)
145     {
146         return new CompositeDoubleValue(this, CompositeDoubleValue.REMAINDER, other);
147     }
148 
remainderOf(SpecificDoubleValue other)149     public DoubleValue remainderOf(SpecificDoubleValue other)
150     {
151         return new CompositeDoubleValue(other, CompositeDoubleValue.REMAINDER, this);
152     }
153 
compare(SpecificDoubleValue other)154     public IntegerValue compare(SpecificDoubleValue other)
155     {
156         return ValueFactory.INTEGER_VALUE;
157 
158         // Not handling NaN properly.
159         //return this.equals(other) ?
160         //    ParticularValueFactory.INTEGER_VALUE_0 :
161         //    new ComparisonValue(this, other);
162     }
163 
164 
165     // Implementations for Value.
166 
isSpecific()167     public boolean isSpecific()
168     {
169         return true;
170     }
171 
172 
173     // Implementations for Object.
174 
equals(Object object)175     public boolean equals(Object object)
176     {
177         return object != null &&
178                this.getClass() == object.getClass();
179     }
180 
181 
hashCode()182     public int hashCode()
183     {
184         return this.getClass().hashCode();
185     }
186 }
187