Beispiel #1
0
        public virtual void ReplaceStatement(Statement oldstat, Statement newstat)
        {
            foreach (StatEdge edge in oldstat.GetAllPredecessorEdges())
            {
                oldstat.RemovePredecessor(edge);
                edge.GetSource().ChangeEdgeNode(Direction_Forward, edge, newstat);
                newstat.AddPredecessor(edge);
            }
            foreach (StatEdge edge in oldstat.GetAllSuccessorEdges())
            {
                oldstat.RemoveSuccessor(edge);
                edge.SetSource(newstat);
                newstat.AddSuccessor(edge);
            }
            int statindex = stats.GetIndexByKey(oldstat.id);

            stats.RemoveWithKey(oldstat.id);
            stats.AddWithKeyAndIndex(statindex, newstat, newstat.id);
            newstat.SetParent(this);
            newstat.post = oldstat.post;
            if (first == oldstat)
            {
                first = newstat;
            }
            List <StatEdge> lst = new List <StatEdge>(oldstat.GetLabelEdges());

            for (int i = lst.Count - 1; i >= 0; i--)
            {
                StatEdge edge = lst[i];
                if (edge.GetSource() != newstat)
                {
                    newstat.AddLabeledEdge(edge);
                }
                else if (this == edge.GetDestination() || this.ContainsStatementStrict(edge.GetDestination
                                                                                           ()))
                {
                    edge.closure = null;
                }
                else
                {
                    this.AddLabeledEdge(edge);
                }
            }
            oldstat.GetLabelEdges().Clear();
        }