1 26 27 package net.sourceforge.groboutils.codecoverage.v2.compiler; 28 29 import java.util.Iterator ; 30 import java.util.LinkedList ; 31 import java.util.List ; 32 33 import org.apache.bcel.generic.Instruction; 34 import org.apache.bcel.generic.InstructionHandle; 35 import org.apache.bcel.generic.InstructionList; 36 37 45 public class MarkedInstruction 46 { 47 private static final org.apache.log4j.Logger LOG = 48 org.apache.log4j.Logger.getLogger( MarkedInstruction.class ); 49 private final InstructionHandle origInstr; 50 private final List marks = new LinkedList (); 51 private boolean closed = false; 52 53 54 57 private final int classSigPoolIndex; 58 59 62 private final int staticMethodPoolIndex; 63 64 67 private final short methodIndex; 68 69 73 MarkedInstruction( short methodIndex, int classSigPoolIndex, 74 int staticMethodPoolIndex, InstructionHandle instr ) 75 { 76 if (instr == null) 77 { 78 throw new IllegalArgumentException ("no null args"); 79 } 80 this.origInstr = instr; 81 this.methodIndex = methodIndex; 82 this.classSigPoolIndex = classSigPoolIndex; 83 this.staticMethodPoolIndex = staticMethodPoolIndex; 84 } 85 86 87 95 InstructionList getMarkedList() 96 { 97 InstructionList markedList = null; 98 if (!this.marks.isEmpty()) 99 { 100 markedList = new InstructionList(); 101 Iterator iter = this.marks.iterator(); 103 while (iter.hasNext()) 104 { 105 LOG.debug( "Adding mark to list." ); 106 ((MeasureMark)iter.next()).addToInstructionList( markedList ); 107 } 108 markedList.setPositions( true ); 109 this.marks.clear(); 112 } 113 return markedList; 114 } 115 116 117 public int getInstructionPosition() 118 { 119 return this.origInstr.getPosition(); 120 } 121 122 123 126 public Instruction getInstruction() 127 { 128 return this.origInstr.getInstruction(); 129 } 130 131 132 137 public void addMark( short measureIndex, short markIndex ) 138 { 139 MeasureMark mm = new MeasureMark( this.classSigPoolIndex, 140 this.staticMethodPoolIndex, this.methodIndex, 141 measureIndex, markIndex ); 142 this.marks.add( mm ); 143 } 144 145 146 149 InstructionHandle getHandle() 150 { 151 return this.origInstr; 152 } 153 } 154 155 | Popular Tags |