1 21 package proguard.evaluation; 22 23 import proguard.evaluation.value.*; 24 25 29 class MutableValue extends Category1Value 30 { 31 private Value containedValue; 32 33 34 38 public void generalizeContainedValue(Value otherContainedValue) 39 { 40 MutableValue lastMutableValue = lastMutableValue(); 41 Value lastContainedValue= lastMutableValue.containedValue; 42 43 lastMutableValue.containedValue = 44 lastContainedValue == null ? otherContainedValue : 45 otherContainedValue.generalize(lastContainedValue); 46 } 47 48 49 52 public void setContainedValue(Value containedValue) 53 { 54 lastMutableValue().containedValue = containedValue; 55 } 56 57 58 61 public Value getContainedValue() 62 { 63 return lastMutableValue().containedValue; 64 } 65 66 67 69 public Value generalize(Value other) 70 { 71 MutableValue otherMutableValue = (MutableValue)other; 72 73 MutableValue thisLastMutableValue = this.lastMutableValue(); 74 MutableValue otherLastMutableValue = otherMutableValue.lastMutableValue(); 75 76 Value thisLastContainedValue = thisLastMutableValue.containedValue; 77 Value otherLastContainedValue = otherLastMutableValue.containedValue; 78 79 if (thisLastMutableValue != otherLastMutableValue) 80 { 81 otherLastMutableValue.containedValue = thisLastMutableValue; 82 } 83 84 thisLastMutableValue.containedValue = 85 thisLastContainedValue == null ? otherLastContainedValue : 86 otherLastContainedValue == null ? thisLastContainedValue : 87 thisLastContainedValue.generalize(otherLastContainedValue); 88 return thisLastMutableValue; 89 } 90 91 92 public int computationalType() 93 { 94 return 0; 95 } 96 97 public final String internalType() 98 { 99 return null; 100 } 101 102 103 105 public boolean equals(Object object) 106 { 107 if (object == null || 108 this.getClass() != object.getClass()) 109 { 110 return false; 111 } 112 113 MutableValue other = (MutableValue)object; 114 Value thisContainedValue = this.getContainedValue(); 115 Value otherContainedValue = other.getContainedValue(); 116 return thisContainedValue == null ? 117 otherContainedValue == null : 118 thisContainedValue.equals(otherContainedValue); 119 } 120 121 122 public int hashCode() 123 { 124 Value containedValue = getContainedValue(); 125 return this.getClass().hashCode() ^ 126 (containedValue == null ? 0 : containedValue.hashCode()); 127 } 128 129 130 public String toString() 131 { 132 return containedValue == null ? "none" : containedValue.toString(); 133 } 134 135 136 138 public MutableValue lastMutableValue() 139 { 140 MutableValue mutableValue = this; 141 142 while (mutableValue.containedValue instanceof MutableValue) 143 { 144 mutableValue = (MutableValue)mutableValue.containedValue; 145 } 146 147 return mutableValue; 148 } 149 } 150 | Popular Tags |