Пример #1
0
        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);
        }
Пример #2
0
        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);
                    }
                }
            }
        }
Пример #3
0
        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));
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
 public void Add(PTGNode node)
 {
     nodes.Add(node.Id, node);
 }
Пример #7
0
 public bool Contains(PTGNode node)
 {
     return(this.ContainsNode(node.Id));
 }