public CFGEdge AddEdge(CFGNode source, CFGNode target, BranchConditionType conditionType) { return AddEdge(source, target, new BranchCondition(conditionType)); }
public CFGEdge AddEdge(CFGNodeCluster sourceCluster, CFGNode target) { return AddEdge(sourceCluster.End, target); }
public CFGEdge AddEdge(CFGNode source, CFGNode target) { return (CFGEdge)base.AddEdge(source, target); }
public CFGEdge AddEdge(CFGNode source, CFGNodeCluster targetCluster, BranchConditionType conditionType) { return AddEdge(source, targetCluster.Start, conditionType); }
public CFGEdge AddEdge(CFGNode source, CFGNodeCluster targetCluster) { return AddEdge(source, targetCluster.Start); }
public virtual bool Match(CFGNode node, CFGPatternMatchFlags flags) { CFGPatternMatchFlags currentFlags = SpecialFlags == null ? SpecialFlags.Value : flags; if (FlowControl != null) { if (FlowControl.Value != node.FlowControl) { return false; } } foreach (Predicate<CFGNode> predicate in Predicates) { if (!predicate(node)) { return false; } } if ((currentFlags & CFGPatternMatchFlags.PerfectMatch) > 0) { if (Pattern.OutDegree(this) != node.Graph.OutDegree(node)) { return false; } } // find a match for each edge List<CFGPatternEdge> patternEdges = new List<CFGPatternEdge>(); foreach (QuickGraph.Concepts.IEdge edge in this.Pattern.OutEdges(this)) { patternEdges.Add((CFGPatternEdge)edge); } List<CFGEdge> edges = new List<CFGEdge>(); foreach (QuickGraph.Concepts.IEdge edge in node.Graph.OutEdges(node)) { edges.Add((CFGEdge)edge); } while (patternEdges.Count > 0) { foreach (CFGPatternEdge patternEdge in patternEdges) { bool foundMatch = false; foreach (CFGEdge edge in edges) { if (patternEdge.Match(edge, flags)) { foundMatch = true; patternEdges.Remove(patternEdge); edges.Remove(edge); break; } } if (!foundMatch) { return false; } } } return true; }
public CFGNodeCluster(CFGNodeCluster start, CFGNodeCluster end) { _start = start.Start; _end = end.End; }
public CFGEdge(int id, CFGNode from, CFGNode to) : base(id, from, to) { }
public CFGEdge AddEdge(CFGNodeCluster sourceCluster, CFGNode target, BranchConditionType conditionType) { return AddEdge(sourceCluster.End, target, conditionType); }
public CFGNode[] Successors(CFGNode node) { List<CFGNode> nodes = new List<CFGNode>(); EdgeCollection edges = this.OutEdges(node); foreach (IEdge edge in edges) { CFGNode targetNode = (CFGNode)edge.Target; if (!nodes.Contains(targetNode)) { nodes.Add(targetNode); } } return nodes.ToArray(); }
public InEdgePredicate(CFGNode target) { Target = target; }
public CFGNode[] Predecessors(CFGNode node) { List<CFGNode> nodes = new List<CFGNode>(); EdgeCollection edges = InEdges(node); foreach (IEdge edge in edges) { CFGNode sourceNode = (CFGNode)edge.Source; if (!nodes.Contains(sourceNode)) { nodes.Add(sourceNode); } } return nodes.ToArray(); }
public void InsertAfter(CFGNode node, CFGNode insertAfterMe) { // all out edges of insertAfterMe become out edges of node List<CFGEdge> edgesToRemove = new List<CFGEdge>(); foreach (CFGEdge outEdge in OutEdges(insertAfterMe)) { AddEdge(node, outEdge.Target, outEdge.BranchCondition); edgesToRemove.Add(outEdge); } foreach (CFGEdge edgeToRemove in edgesToRemove) { RemoveEdge(edgeToRemove); } // now add an edge from insertAfterme to node AddEdge(insertAfterMe, node, BranchConditionType.Unconditional); }
// TODO: Cache data in CFG (cache is cleared when an edge or node is added or removed) public EdgeCollection InEdges(CFGNode node) { FilteredEdgeEnumerable edges = this.SelectEdges(new InEdgePredicate(node)); return new EdgeCollection(edges); }
public CFGEdge AddEdge(CFGNode source, CFGNode target, BranchCondition condition) { CFGEdge edge = (CFGEdge)base.AddEdge(source, target); edge.BranchCondition = condition; return edge; }
public CFGNodeCluster(CFGNode start, CFGNode end) { _start = start; _end = end; }
public CFGNode AddNode() { CFGNode newNode = (CFGNode)base.AddVertex(); if (_root == null) { _root = newNode; } return newNode; }
// TODO: Move ReplaceRoot into BasicMiddleEnd - MethodCompileInfo should only contain state information, and compiler tiers should manipulate that state public void ReplaceRoot(CFGNode root, CFGNode replacement) { if (_cfg.Root == root) { _cfg.Root = replacement; } else { foreach (TryBlockInfo tryBlockInfo in _tryBlockInfos) { foreach (CFGNodeCluster handlerCluster in tryBlockInfo.Handlers.Keys) { if (handlerCluster.Start == root) { handlerCluster.Start = replacement; } } } } }