public PointsToGraph() { this.Null = new PTGNode(0, PTGNodeKind.Null); this.variables = new MapSet <IVariable, PTGNode>(); this.nodes = new Dictionary <int, PTGNode>(); this.Add(this.Null); }
public void Union(PointsToGraph ptg) { // add all new nodes foreach (var node in ptg.Nodes) { if (this.Contains(node)) { continue; } var clone = new PTGNode(node.Id, node.Type, node.Offset, node.Kind); nodes.Add(clone.Id, clone); } // add all variables foreach (var variable in ptg.Variables) { this.variables.Add(variable); } // add all edges foreach (var node in ptg.Nodes) { var clone = nodes[node.Id]; // add variable <---> node edges foreach (var variable in node.Variables) { clone.Variables.Add(variable); this.variables.Add(variable, clone); } // add source -field-> node edges foreach (var entry in node.Sources) { foreach (var source in entry.Value) { var source_clone = nodes[source.Id]; clone.Sources.Add(entry.Key, source_clone); } } // add node -field-> target edges foreach (var entry in node.Targets) { foreach (var target in entry.Value) { var target_clone = nodes[target.Id]; clone.Targets.Add(entry.Key, target_clone); } } } }
public bool SameEdges(PTGNode node) { if (node == null) { throw new ArgumentNullException("node"); } return(this.Variables.SetEquals(node.Variables) && this.Sources.MapEquals(node.Sources) && this.Targets.MapEquals(node.Targets)); }
public void PointsTo(IVariable variable, PTGNode target) { #if DEBUG if (!this.Contains(target)) { throw new ArgumentException("Target node does not belong to this Points-to graph.", "target"); } #endif target.Variables.Add(variable); this.variables.Add(variable, target); }
public void PointsTo(PTGNode source, IFieldReference field, PTGNode target) { #if DEBUG if (!this.Contains(source)) { throw new ArgumentException("Source node does not belong to this Points-to graph.", "source"); } if (!this.Contains(target)) { throw new ArgumentException("Target node does not belong to this Points-to graph.", "target"); } #endif source.Targets.Add(field, target); target.Sources.Add(field, source); }
public void Add(PTGNode node) { nodes.Add(node.Id, node); }
public bool Contains(PTGNode node) { return(this.ContainsNode(node.Id)); }