01: package org.hansel.probes;
02:
03: import org.hansel.ProbeData;
04:
05: import org.objectweb.asm.MethodVisitor;
06: import org.objectweb.asm.Opcodes;
07: import org.objectweb.asm.tree.analysis.AnalyzerException;
08:
09: /**
10: * A probe for a comparing conditional branch. For decision coverage both possible
11: * conditions for the branch have to be encountered.
12: *
13: * @author Niklas Mehner.
14: */
15: public class BinaryBranchProbe extends BranchProbe {
16: private IntComparator cmp;
17:
18: public BinaryBranchProbe(ProbeData pd, IntComparator cmp)
19: throws AnalyzerException {
20: super (pd, cmp.createStackEntry(pd.getStackEntry(1), pd
21: .getStackEntry(0)));
22: this .cmp = cmp;
23: }
24:
25: public void hit(int n, int m) {
26: cover(cmp.compare(n, m));
27: }
28:
29: public void insertProbeCode(MethodVisitor cv) {
30: cv.visitInsn(Opcodes.DUP2);
31: cv.visitLdcInsn(new Integer(getID()));
32: cv.visitMethodInsn(Opcodes.INVOKESTATIC, HIT_CLASS,
33: "hitBranch", "(III)V");
34: }
35: }
|