public virtual void SetIfstat(Statement ifstat) { this.ifstat = ifstat; }
private IfStatement(Statement head, int regedges, Statement postst) : this() { first = head; stats.AddWithKey(head, head.id); List <StatEdge> lstHeadSuccs = head.GetSuccessorEdges(Statedge_Direct_All); switch (regedges) { case 0: { ifstat = null; elsestat = null; break; } case 1: { ifstat = null; elsestat = null; StatEdge edgeif = lstHeadSuccs[1]; if (edgeif.GetType() != StatEdge.Type_Regular) { post = lstHeadSuccs[0].GetDestination(); } else { post = edgeif.GetDestination(); negated = true; } break; } case 2: { elsestat = lstHeadSuccs[0].GetDestination(); ifstat = lstHeadSuccs[1].GetDestination(); List <StatEdge> lstSucc = ifstat.GetSuccessorEdges(StatEdge.Type_Regular); List <StatEdge> lstSucc1 = elsestat.GetSuccessorEdges(StatEdge.Type_Regular); if (ifstat.GetPredecessorEdges(StatEdge.Type_Regular).Count > 1 || lstSucc.Count > 1) { post = ifstat; } else if (elsestat.GetPredecessorEdges(StatEdge.Type_Regular).Count > 1 || lstSucc1 .Count > 1) { post = elsestat; } else if (lstSucc.Count == 0) { post = elsestat; } else if (lstSucc1.Count == 0) { post = ifstat; } if (ifstat == post) { if (elsestat != post) { ifstat = elsestat; negated = true; } else { ifstat = null; } elsestat = null; } else if (elsestat == post) { elsestat = null; } else { post = postst; } if (elsestat == null) { regedges = 1; } break; } } // if without else ifedge = lstHeadSuccs[negated ? 0 : 1]; elseedge = (regedges == 2) ? lstHeadSuccs[negated ? 1 : 0] : null; iftype = (regedges == 2) ? Iftype_Ifelse : Iftype_If; if (iftype == Iftype_If) { if (regedges == 0) { StatEdge edge = lstHeadSuccs[0]; head.RemoveSuccessor(edge); edge.SetSource(this); this.AddSuccessor(edge); } else if (regedges == 1) { StatEdge edge = lstHeadSuccs[negated ? 1 : 0]; head.RemoveSuccessor(edge); } } if (ifstat != null) { stats.AddWithKey(ifstat, ifstat.id); } if (elsestat != null) { stats.AddWithKey(elsestat, elsestat.id); } if (post == head) { post = this; } }
public virtual void SetElsestat(Statement elsestat) { this.elsestat = elsestat; }