2
* ProGuard -- shrinking, optimization, obfuscation, and preverification
5
* Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu)
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)
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
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
21
package proguard.evaluation.value;
23
import proguard.classfile.Clazz;
26
* This ReferenceValue represents a partially evaluated array. It has an array
27
* length and possibly array values (up to a fixed maximum number). It is not
30
* @author Eric Lafortune
32
class ArrayReferenceValue extends TypedReferenceValue
34
protected final IntegerValue arrayLength;
38
* Creates a new ArrayReferenceValue.
40
public ArrayReferenceValue(String type,
41
Clazz referencedClass,
42
IntegerValue arrayLength)
44
super(type, referencedClass, false);
46
this.arrayLength = arrayLength;
50
// Implementations for ReferenceValue.
52
public IntegerValue arrayLength(ValueFactory valueFactory)
58
// Implementations of binary methods of ReferenceValue.
60
public ReferenceValue generalize(ReferenceValue other)
62
return other.generalize(this);
66
public int equal(ReferenceValue other)
68
return other.equal(this);
72
// // Implementations of binary ReferenceValue methods with
73
// // IdentifiedReferenceValue arguments.
75
// public ReferenceValue generalize(IdentifiedReferenceValue other)
77
// return generalize((TypedReferenceValue)other);
81
// public int equal(IdentifiedReferenceValue other)
83
// return equal((TypedReferenceValue)other);
87
// Implementations of binary ReferenceValue methods with
88
// ArrayReferenceValue arguments.
90
public ReferenceValue generalize(ArrayReferenceValue other)
93
this.equals(other) ? this :
95
this.type.equals(other.type) &&
96
this.referencedClass == other.referencedClass ? new ArrayReferenceValue(this.type,
98
this.arrayLength.generalize(other.arrayLength)) :
99
generalize((TypedReferenceValue)other);
103
public int equal(ArrayReferenceValue other)
105
if (this.arrayLength.equal(other.arrayLength) == NEVER)
110
return equal((TypedReferenceValue)other);
114
// // Implementations of binary ReferenceValue methods with
115
// // IdentifiedArrayReferenceValue arguments.
117
// public ReferenceValue generalize(IdentifiedArrayReferenceValue other)
119
// return generalize((ArrayReferenceValue)other);
123
// public int equal(IdentifiedArrayReferenceValue other)
125
// return equal((ArrayReferenceValue)other);
129
// // Implementations of binary ReferenceValue methods with
130
// // DetailedArrayReferenceValue arguments.
132
// public ReferenceValue generalize(DetailedArrayReferenceValue other)
134
// return generalize((IdentifiedArrayReferenceValue)other);
138
// public int equal(DetailedArrayReferenceValue other)
140
// return equal((IdentifiedArrayReferenceValue)other);
144
// Implementations for Object.
146
public boolean equals(Object object)
148
return this == object ||
149
super.equals(object) &&
150
this.arrayLength.equals(((ArrayReferenceValue)object).arrayLength);
154
public int hashCode()
156
return super.hashCode() ^
157
arrayLength.hashCode();
161
public String toString()
163
return super.toString() + '['+arrayLength+']';