// ***************************************************************************** // public methods // ***************************************************************************** public static Statement IsHead(Statement head) { if (head.GetLastBasicType() != Statement.Lastbasictype_General) { return(null); } HashSet <Statement> setHandlers = DecHelper.GetUniquePredExceptions(head); if (setHandlers.Count != 1) { return(null); } foreach (StatEdge edge in head.GetSuccessorEdges(StatEdge.Type_Exception)) { Statement exc = edge.GetDestination(); if (edge.GetExceptions() == null && exc.GetLastBasicType() == Lastbasictype_General && setHandlers.Contains(exc)) { List <StatEdge> lstSuccs = exc.GetSuccessorEdges(Statedge_Direct_All); if ((lstSuccs.Count == 0) || lstSuccs[0].GetType() != StatEdge.Type_Regular) { if (head.IsMonitorEnter() || exc.IsMonitorEnter()) { return(null); } if (DecHelper.CheckStatementExceptions(Sharpen.Arrays.AsList(head, exc))) { return(new CatchAllStatement(head, exc)); } } } } return(null); }
// ***************************************************************************** // public methods // ***************************************************************************** public static Statement IsHead2Block(Statement head) { if (head.GetLastBasicType() != Statement.Lastbasictype_General) { return(null); } // at most one outgoing edge StatEdge edge = null; List <StatEdge> lstSuccs = head.GetSuccessorEdges(Statedge_Direct_All); if (!(lstSuccs.Count == 0)) { edge = lstSuccs[0]; } if (edge != null && edge.GetType() == StatEdge.Type_Regular) { Statement stat = edge.GetDestination(); if (stat != head && stat.GetPredecessorEdges(StatEdge.Type_Regular).Count == 1 && !stat.IsMonitorEnter()) { if (stat.GetLastBasicType() == Statement.Lastbasictype_General) { if (DecHelper.CheckStatementExceptions(Sharpen.Arrays.AsList(head, stat))) { return(new SequenceStatement(head, stat)); } } } } return(null); }
// post is always null! // ***************************************************************************** // public methods // ***************************************************************************** public static Statement IsHead(Statement head) { if (head.GetLastBasicType() == Lastbasictype_General && !head.IsMonitorEnter()) { // at most one outgoing edge StatEdge edge = null; List <StatEdge> lstSuccs = head.GetSuccessorEdges(Statedge_Direct_All); if (!(lstSuccs.Count == 0)) { edge = lstSuccs[0]; } // regular loop if (edge != null && edge.GetType() == StatEdge.Type_Regular && edge.GetDestination () == head) { return(new DoStatement(head)); } // continues if (head.type != Type_Do && (edge == null || edge.GetType() != StatEdge.Type_Regular ) && head.GetContinueSet().Contains(head.GetBasichead())) { return(new DoStatement(head)); } } return(null); }