@Override /** Verifies that the begin, end and handler units of each trap are in this body. */ public void validate(Body body, List<ValidationException> exception) { PatchingChain<Unit> units = body.getUnits(); for (Trap t : body.getTraps()) { if (!units.contains(t.getBeginUnit())) { exception.add(new ValidationException(t.getBeginUnit(), "begin not in chain" + " in " + body.getMethod())); } if (!units.contains(t.getEndUnit())) { exception.add(new ValidationException(t.getEndUnit(), "end not in chain" + " in " + body.getMethod())); } if (!units.contains(t.getHandlerUnit())) { exception.add(new ValidationException(t.getHandlerUnit(), "handler not in chain" + " in " + body.getMethod())); } } }
/** Removes the given object from this Chain. */ @Override @SuppressWarnings("unchecked") public boolean remove(Object obj) { boolean res = false; if (contains(obj)) { Unit successor = getSuccOf((E) obj); if (successor == null) { successor = getPredOf((E) obj); } // Note that redirecting to the last unit in the method // like this is probably incorrect when dealing with a Trap. // I.e., let's say that the final unit in the method used to // be U10, preceded by U9, and that there was a Trap which // returned U10 as getEndUnit(). I.e., before the trap covered U9. // When we redirect the Trap's end unit to U9, the trap will no // longer cover U9. I know this is incorrect, but I'm not sure how // to fix it, so I'm leaving this comment in the hopes that some // future maintainer will see the right course to take. res = innerChain.remove(obj); ((E) obj).redirectJumpsToThisTo(successor); } return res; }
public void validateLocalVariables() { Iterator<LocalVariable> it = getLocalVariables().iterator(); while (it.hasNext()) { LocalVariable lv = it.next(); if (!unitChain.contains(lv.getStartUnit())) throw new RuntimeException("start not in chain"+" in "+getMethod()); if (lv.getEndUnit() != null && !unitChain.contains(lv.getEndUnit())) throw new RuntimeException("end not in chain"+" in "+getMethod()); } }
public void validateLocalVariables() { Iterator<LocalVariable> it = getLocalVariables().iterator(); while (it.hasNext()) { LocalVariable lv = it.next(); if (!unitChain.contains(lv.getStartUnit())) throw new RuntimeException("start not in chain"+" in "+getMethod()); if (lv.getEndUnit() != null && !unitChain.contains(lv.getEndUnit())) throw new RuntimeException("end not in chain"+" in "+getMethod()); } }
/** Verifies that the UnitBoxes of this Body all point to a Unit contained within this body. */ public void validateUnitBoxes() { Iterator<UnitBox> it = getAllUnitBoxes().iterator(); while (it.hasNext()) { UnitBox ub = it.next(); if (!unitChain.contains(ub.getUnit())) throw new RuntimeException ("Unitbox points outside unitChain! to unit : "+ub.getUnit()+" in "+getMethod()); } }
/** Verifies that the begin, end and handler units of each trap are in this body. */ public void validateTraps() { Iterator<Trap> it = getTraps().iterator(); while (it.hasNext()) { Trap t = it.next(); if (!unitChain.contains(t.getBeginUnit())) throw new RuntimeException("begin not in chain"+" in "+getMethod()); if (!unitChain.contains(t.getEndUnit())) throw new RuntimeException("end not in chain"+" in "+getMethod()); if (!unitChain.contains(t.getHandlerUnit())) throw new RuntimeException("handler not in chain"+" in "+getMethod()); } }
/** Verifies that the UnitBoxes of this Body all point to a Unit contained within this body. */ public void validateUnitBoxes() { Iterator<UnitBox> it = getAllUnitBoxes().iterator(); while (it.hasNext()) { UnitBox ub = it.next(); if (!unitChain.contains(ub.getUnit())) throw new RuntimeException ("Unitbox points outside unitChain! to unit : "+ub.getUnit()+" in "+getMethod()); } }
/** Verifies that the begin, end and handler units of each trap are in this body. */ public void validateTraps() { Iterator<Trap> it = getTraps().iterator(); while (it.hasNext()) { Trap t = it.next(); if (!unitChain.contains(t.getBeginUnit())) throw new RuntimeException("begin not in chain"+" in "+getMethod()); if (!unitChain.contains(t.getEndUnit())) throw new RuntimeException("end not in chain"+" in "+getMethod()); if (!unitChain.contains(t.getHandlerUnit())) throw new RuntimeException("handler not in chain"+" in "+getMethod()); } }
/** Removes the given object from this Chain. */ @SuppressWarnings("unchecked") public boolean remove(Object obj) { boolean res = false; if(contains(obj)) { Unit successor; if((successor = getSuccOf((E) obj)) == null) successor = getPredOf((E) obj); // Note that redirecting to the last unit in the method // like this is probably incorrect when dealing with a Trap. // I.e., let's say that the final unit in the method used to // be U10, preceded by U9, and that there was a Trap which // returned U10 as getEndUnit(). I.e., before the trap covered U9. // When we redirect the Trap's end unit to U9, the trap will no // longer cover U9. I know this is incorrect, but I'm not sure how // to fix it, so I'm leaving this comment in the hopes that some // future maintainer will see the right course to take. res = innerChain.remove(obj); ((E)obj).redirectJumpsToThisTo(successor); } return res; }
/** Removes the given object from this Chain. */ @SuppressWarnings("unchecked") public boolean remove(Object obj) { boolean res = false; if(contains(obj)) { Unit successor; if((successor = getSuccOf((E) obj)) == null) successor = getPredOf((E) obj); // Note that redirecting to the last unit in the method // like this is probably incorrect when dealing with a Trap. // I.e., let's say that the final unit in the method used to // be U10, preceded by U9, and that there was a Trap which // returned U10 as getEndUnit(). I.e., before the trap covered U9. // When we redirect the Trap's end unit to U9, the trap will no // longer cover U9. I know this is incorrect, but I'm not sure how // to fix it, so I'm leaving this comment in the hopes that some // future maintainer will see the right course to take. res = innerChain.remove(obj); ((E)obj).redirectJumpsToThisTo(successor); } return res; }