1 /* 2 * ProGuard -- shrinking, optimization, obfuscation, and preverification 3 * of Java bytecode. 4 * 5 * Copyright (c) 2002-2014 Eric Lafortune (eric (at) 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.Clazz; 24 25 /** 26 * This ArrayReferenceValue represents an array reference value that is 27 * identified by a unique ID. 28 * 29 * @author Eric Lafortune 30 */ 31 class IdentifiedArrayReferenceValue extends ArrayReferenceValue 32 { 33 private final ValueFactory valuefactory; 34 private final int id; 35 36 37 /** 38 * Creates a new array reference value with the given ID. 39 */ 40 public IdentifiedArrayReferenceValue(String type, 41 Clazz referencedClass, 42 IntegerValue arrayLength, 43 ValueFactory valuefactory, 44 int id) 45 { 46 super(type, referencedClass, arrayLength); 47 48 this.valuefactory = valuefactory; 49 this.id = id; 50 } 51 52 53 // Implementations of binary methods of ReferenceValue. 54 55 public ReferenceValue generalize(ReferenceValue other) 56 { 57 return other.generalize(this); 58 } 59 60 61 public int equal(ReferenceValue other) 62 { 63 return other.equal(this); 64 } 65 66 67 // // Implementations of binary ReferenceValue methods with 68 // // IdentifiedReferenceValue arguments. 69 // 70 // public ReferenceValue generalize(IdentifiedReferenceValue other) 71 // { 72 // return generalize((TypedReferenceValue)other); 73 // } 74 // 75 // 76 // public int equal(IdentifiedReferenceValue other) 77 // { 78 // return equal((TypedReferenceValue)other); 79 // } 80 // 81 // 82 // // Implementations of binary ReferenceValue methods with 83 // // ArrayReferenceValue arguments. 84 // 85 // public ReferenceValue generalize(ArrayReferenceValue other) 86 // { 87 // return generalize((TypedReferenceValue)other); 88 // } 89 // 90 // 91 // public int equal(ArrayReferenceValue other) 92 // { 93 // return equal((TypedReferenceValue)other); 94 // } 95 // 96 // 97 // Implementations of binary ReferenceValue methods with 98 // IdentifiedArrayReferenceValue arguments. 99 100 // public ReferenceValue generalize(IdentifiedArrayReferenceValue other) 101 // { 102 // return generalize((ArrayReferenceValue)other); 103 // } 104 105 106 public int equal(IdentifiedArrayReferenceValue other) 107 { 108 return this.equals(other) ? ALWAYS : 109 this.equal((TypedReferenceValue)other); 110 } 111 112 113 // // Implementations of binary ReferenceValue methods with 114 // // DetailedArrayReferenceValue arguments. 115 // 116 // public ReferenceValue generalize(DetailedArrayReferenceValue other) 117 // { 118 // return generalize((IdentifiedArrayReferenceValue)other); 119 // } 120 // 121 // 122 // public int equal(DetailedArrayReferenceValue other) 123 // { 124 // return equal((IdentifiedArrayReferenceValue)other); 125 // } 126 127 128 // Implementations for Value. 129 130 public boolean isSpecific() 131 { 132 return true; 133 } 134 135 136 // Implementations for Object. 137 138 public boolean equals(Object object) 139 { 140 return this == object || 141 super.equals(object) && 142 this.valuefactory.equals(((IdentifiedArrayReferenceValue)object).valuefactory) && 143 this.id == ((IdentifiedArrayReferenceValue)object).id; 144 } 145 146 147 public int hashCode() 148 { 149 return super.hashCode() ^ 150 valuefactory.hashCode() ^ 151 id; 152 } 153 154 155 public String toString() 156 { 157 return super.toString() + '#' + id; 158 } 159 }