1 6 package de.uka.ipd.coverage.recording; 7 8 import java.io.Serializable ; 9 10 14 15 public class RuntimeBasicBlockWrapper 16 implements IBasicBlock, Cloneable , Serializable { 17 18 private IBasicBlock basicblock; 19 private boolean entered; 20 private boolean exited; 21 22 23 26 public RuntimeBasicBlockWrapper(IBasicBlock basicblock) { 27 this.basicblock = basicblock; 28 } 29 30 public void triggerEntered() { 31 this.entered = true; 32 } 33 34 public void triggerExited() { 35 assert isEntered() : "call triggerEntered before calling triggerExited!"; this.exited = true; 37 } 38 39 public boolean isEntered() { 40 return entered; 41 } 42 public boolean isExited() { 43 return exited; 44 } 45 46 public int getStartLine() { 47 return this.basicblock.getStartLine(); 48 } 49 50 public int getEndLine() { 51 return this.basicblock.getEndLine(); 52 } 53 54 public RegisteredMethod getRegisteredMethod() { 55 return this.basicblock.getRegisteredMethod(); 56 } 57 58 public CoverageState covers(IBasicBlock obj) { 59 CoverageState result = this.basicblock.covers(obj); 60 if (obj instanceof RuntimeBasicBlockWrapper 61 && result == CoverageState.FULL_COVERAGE) { 62 73 RuntimeBasicBlockWrapper wrapper = (RuntimeBasicBlockWrapper) obj; 74 if (wrapper.entered) { 75 if (wrapper.exited) { 76 return CoverageState.FULL_COVERAGE; 77 } else if (this.exited) { 78 return CoverageState.PARTIAL_COVERAGE; 79 } 80 return CoverageState.FULL_COVERAGE; 81 } else { 82 if (this.entered) { 83 return CoverageState.FULL_COVERAGE; 84 } 85 return CoverageState.NO_COVERAGE; 86 } 87 } 88 return result; 89 } 90 91 public boolean referencesSameBytecodeAs(BasicBlock compBlock) { 92 return this.basicblock.referencesSameBytecodeAs(compBlock); 93 } 94 95 public boolean equals(Object obj) { 96 boolean result = false; 97 if (obj instanceof RuntimeBasicBlockWrapper) { 98 RuntimeBasicBlockWrapper compWrapper = (RuntimeBasicBlockWrapper) obj; 99 result = this.basicblock.equals(compWrapper.basicblock); 100 result = result 101 & this.entered == compWrapper.entered 102 & this.exited == compWrapper.exited; 103 return result; 104 } 105 if (obj instanceof BasicBlock) { 106 IBasicBlock compBlock = (IBasicBlock) obj; 107 result = this.basicblock.equals(compBlock); 108 return result; 109 } 110 return false; 111 } 112 113 public Object clone() { 114 RuntimeBasicBlockWrapper result = 115 new RuntimeBasicBlockWrapper(this.basicblock); 116 result.entered = this.entered; 117 result.exited = this.exited; 118 return result; 119 } 120 public IBasicBlock getWrappedBasicBlock() { 121 return basicblock; 122 } 123 124 public String toString() { 125 return basicblock.toString(); 126 } 127 } 128 | Popular Tags |