1 19 20 package edu.umd.cs.findbugs.ba; 21 22 import edu.umd.cs.findbugs.annotations.Nullable; 23 24 32 public abstract class FrameDataflowAnalysis <ValueType, FrameType extends Frame<ValueType>> extends ForwardDataflowAnalysis<FrameType> { 33 public FrameDataflowAnalysis(DepthFirstSearch dfs) { 34 super(dfs); 35 } 36 37 public void copy(FrameType source, FrameType dest) { 38 dest.copyFrom(source); 39 } 40 41 public void initResultFact(FrameType result) { 42 result.setTop(); 43 } 44 45 public void makeFactTop(FrameType fact) { 46 fact.setTop(); 47 } 48 public boolean isTop(FrameType fact) { 49 return fact.isTop(); 50 } 51 public boolean same(FrameType fact1, FrameType fact2) { 52 return fact1.sameAs(fact2); 53 } 54 55 @Override 56 public boolean isFactValid(FrameType fact) { 57 return fact.isValid(); 58 } 59 60 @Override 61 public int getLastUpdateTimestamp(FrameType fact) { 62 return fact.getLastUpdateTimestamp(); 63 } 64 @Override 65 public void setLastUpdateTimestamp(FrameType fact, int lastTimestamp) { 66 fact.setLastUpdateTimestamp(lastTimestamp); 67 } 68 69 100 final protected FrameType modifyFrame(FrameType orig, @Nullable FrameType copy) { 101 if (copy == null) { 102 copy = createFact(); 103 copy.copyFrom(orig); 104 } 105 return copy; 106 } 107 108 115 protected void mergeInto(FrameType other, FrameType result) throws DataflowAnalysisException { 116 if (result.isTop()) { 118 result.copyFrom(other); 120 return; 121 } else if (other.isTop()) { 122 return; 124 } 125 126 if (result.isBottom()) { 128 return; 130 } else if (other.isBottom()) { 131 result.setBottom(); 133 return; 134 } 135 136 if (result.getNumSlots() != other.getNumSlots()) { 139 result.setBottom(); 140 return; 141 } 142 143 for (int i = 0; i < result.getNumSlots(); ++i) { 146 mergeValues(other, result, i); 147 } 148 } 149 150 158 protected abstract void mergeValues(FrameType otherFrame, FrameType resultFrame, int slot) 159 throws DataflowAnalysisException; 160 } 161 162 | Popular Tags |