public static ISet <IVariable> GetModifiedVariables(this CFGLoop loop) { var result = from n in loop.Body from v in n.GetModifiedVariables() select v; //var result = loop.Body.SelectMany(n => n.GetModifiedVariables()); return(new HashSet <IVariable>(result)); }
public static ISet <CFGNode> GetExitNodes(this CFGLoop loop) { var result = from n in loop.Body from m in n.Successors where !loop.Body.Contains(m) select n; //var result = loop.Body.Where(n => n.Successors.Any(m => !loop.Body.Contains(m))); return(new HashSet <CFGNode>(result)); }
private static CFGLoop IdentifyLoop(CFGEdge back_edge) { var loop = new CFGLoop(back_edge.Target); var nodes = new Stack <CFGNode>(); nodes.Push(back_edge.Source); do { var node = nodes.Pop(); var new_node = loop.Body.Add(node); if (new_node) { foreach (var pred in node.Predecessors) { nodes.Push(pred); } } }while (nodes.Count > 0); return(loop); }