コード例 #1
0
 public virtual void Initialize()
 {
     domEngine = new DominatorEngine(statement);
     domEngine.Initialize();
     BuildDominatorTree();
     BuildExceptionRanges();
     BuildFilter(statement.GetFirst().id);
     // free resources
     mapTreeBranches.Clear();
     mapExceptionRanges.Clear();
 }
コード例 #2
0
        private void FilterOnDominance(DominatorTreeExceptionFilter filter)
        {
            DominatorEngine engine = filter.GetDomEngine();

            foreach (int head in new HashSet <int>(mapExtPostdominators.Keys))
            {
                FastFixedSetFactory <int> .FastFixedSet <int> setPostdoms = mapExtPostdominators.GetOrNull
                                                                                (head);
                LinkedList <Statement> stack = new LinkedList <Statement>();
                LinkedList <FastFixedSetFactory <int> .FastFixedSet <int> > stackPath = new LinkedList <FastFixedSetFactory <int> .FastFixedSet
                                                                                                        <int> >();
                stack.AddLast(statement.GetStats().GetWithKey(head));
                stackPath.AddLast(factory.SpawnEmptySet());
                HashSet <Statement> setVisited = new HashSet <Statement>();
                setVisited.Add(stack.First.Value);
                while (!(stack.Count == 0))
                {
                    Statement stat = Sharpen.Collections.RemoveFirst(stack);
                    FastFixedSetFactory <int> .FastFixedSet <int> path = Sharpen.Collections.RemoveFirst(stackPath
                                                                                                         );
                    if (setPostdoms.Contains(stat.id))
                    {
                        path.Add(stat.id);
                    }
                    if (path.Contains(setPostdoms))
                    {
                        continue;
                    }
                    if (!engine.IsDominator(stat.id, head))
                    {
                        setPostdoms.Complement(path);
                        continue;
                    }
                    foreach (StatEdge edge in stat.GetSuccessorEdges(StatEdge.Type_Regular))
                    {
                        Statement edge_destination = edge.GetDestination();
                        if (!setVisited.Contains(edge_destination))
                        {
                            stack.AddLast(edge_destination);
                            stackPath.AddLast(path.GetCopy());
                            setVisited.Add(edge_destination);
                        }
                    }
                }
                if (setPostdoms.IsEmpty())
                {
                    Sharpen.Collections.Remove(mapExtPostdominators, head);
                }
            }
        }