1 19 20 package edu.umd.cs.findbugs.ba.type; 21 22 import static edu.umd.cs.findbugs.ba.Debug.VERIFY_INTEGRITY; 23 24 import java.util.BitSet ; 25 26 import org.apache.bcel.generic.Type; 27 28 import edu.umd.cs.findbugs.ba.DataflowAnalysisException; 29 import edu.umd.cs.findbugs.ba.Frame; 30 import edu.umd.cs.findbugs.ba.vna.ValueNumber; 31 32 40 public class TypeFrame extends Frame<Type> { 41 private BitSet exactTypeSet; 42 43 46 public TypeFrame(int numLocals) { 47 super(numLocals); 48 this.exactTypeSet = new BitSet (); 49 } 50 51 57 public void setExact(int slot, boolean isExact) { 58 exactTypeSet.set(slot, isExact); 59 } 60 61 67 public boolean isExact(int slot) { 68 return exactTypeSet.get(slot); 69 } 70 71 76 public void clearExactSet() { 77 exactTypeSet.clear(); 78 } 79 80 @Override 81 public void setTop() { 82 super.setTop(); 83 clearExactSet(); 84 } 85 86 @Override 87 public void copyFrom(Frame<Type> other_) { 88 clearExactSet(); 89 90 TypeFrame other = (TypeFrame) other_; 91 92 this.exactTypeSet.or(other.exactTypeSet); 93 94 super.copyFrom(other_); 95 } 96 97 @Override 98 protected String valueToString(Type value) { 99 return value.toString() + ","; 100 } 101 102 105 public static Type getTopType() { 106 return TopType.instance(); 107 } 108 109 112 public static Type getBottomType() { 113 return BottomType.instance(); 114 } 115 116 119 public static Type getLongExtraType() { 120 return LongExtraType.instance(); 121 } 122 123 126 public static Type getDoubleExtraType() { 127 return DoubleExtraType.instance(); 128 } 129 130 133 public static Type getNullType() { 134 return NullType.instance(); 135 } 136 137 @Override 138 public void pushValue(Type value) { 139 140 super.pushValue(value); 141 142 try { 143 exactTypeSet.clear(getStackLocation(0)); 144 } catch (DataflowAnalysisException e) { 145 assert false; 146 } 147 148 } 149 150 157 @Override 158 public Type popValue() throws DataflowAnalysisException { 159 160 exactTypeSet.clear(getStackLocation(0)); 161 return super.popValue(); 162 } 163 164 165 166 167 } 168 169 | Popular Tags |