1 5 package de.uka.ipd.coverage.recording; 6 7 8 9 18 public class BasicBlockBuilder { 19 20 private BasicBlock block; 21 private RegisteredMethod method; 22 private int startLine; 23 private int endLine; 24 25 26 public void createBasicBlock() { 27 this.block = null; 28 this.method = null; 29 this.startLine = Integer.MIN_VALUE; 30 this.endLine = Integer.MIN_VALUE; 31 } 32 33 34 public void setEndLine(int endLine) { 35 this.endLine = endLine; 36 } 37 38 public void setRegisteredMethod(RegisteredMethod method) { 39 this.method = method; 40 } 41 public void setStartLine(int startLine) { 42 this.startLine = startLine; 43 } 44 45 public BasicBlock getBasicBlock() { 46 if (this.method == null) { 47 throw new IllegalArgumentException ("You must call setRegisteredMethod() before" + " calling getBlock()"); } 50 if (this.startLine == Integer.MIN_VALUE) { 51 throw new IllegalArgumentException ("You must call setStartLine() before" + " calling getBlock()"); } 54 if (this.endLine == Integer.MIN_VALUE) { 55 throw new IllegalArgumentException ("You must call setEndLine() before" + " calling getBlock()"); } 58 59 if (this.block == null) { 60 this.block = createBlock(); 61 } 62 return this.block; 63 } 64 65 private BasicBlock createBlock() { 66 BasicBlock block = new BasicBlock(method); 67 block.setStartLine(startLine); 68 block.setEndLine(endLine); 69 return block; 70 } 71 72 } 73 | Popular Tags |