Example #1
0
 public static void EnhanceLoops(Statement root)
 {
     while (EnhanceLoopsRec(root))
     {
     }
     /**/
     SequenceHelper.CondenseSequences(root);
 }
Example #2
0
        public static bool ExtractLoops(Statement root)
        {
            bool res = (ExtractLoopsRec(root) != 0);

            if (res)
            {
                SequenceHelper.CondenseSequences(root);
            }
            return(res);
        }
Example #3
0
        public static bool MergeAllIfs(RootStatement root)
        {
            bool res = MergeAllIfsRec(root, new HashSet <int>());

            if (res)
            {
                SequenceHelper.CondenseSequences(root);
            }
            return(res);
        }
        public static bool InlineSingleBlocks(RootStatement root)
        {
            bool res = InlineSingleBlocksRec(root);

            if (res)
            {
                SequenceHelper.CondenseSequences(root);
            }
            return(res);
        }
Example #5
0
        public static bool CondenseExits(RootStatement root)
        {
            int changed = IntegrateExits(root);

            if (changed > 0)
            {
                CleanUpUnreachableBlocks(root);
                SequenceHelper.CondenseSequences(root);
            }
            return(changed > 0);
        }
Example #6
0
        public static RootStatement ParseGraph(ControlFlowGraph graph)
        {
            RootStatement root = GraphToStatement(graph);

            if (!ProcessStatement(root, new Dictionary <int, HashSet <int> >()))
            {
                //			try {
                //				DotExporter.toDotFile(root.getFirst().getStats().get(13), new File("c:\\Temp\\stat1.dot"));
                //			} catch (Exception ex) {
                //				ex.printStackTrace();
                //			}
                throw new Exception("parsing failure!");
            }
            LabelHelper.LowContinueLabels(root, new HashSet <StatEdge>());
            SequenceHelper.CondenseSequences(root);
            root.BuildMonitorFlags();
            // build synchronized statements
            BuildSynchronized(root);
            return(root);
        }
Example #7
0
        public virtual void SimplifyStackVars(RootStatement root, StructMethod mt, StructClass
                                              cl)
        {
            HashSet <int>           setReorderedIfs = new HashSet <int>();
            SSAUConstructorSparseEx ssau            = null;

            while (true)
            {
                bool found = false;
                SSAConstructorSparseEx ssa = new SSAConstructorSparseEx();
                ssa.SplitVariables(root, mt);
                SimplifyExprentsHelper sehelper = new SimplifyExprentsHelper(ssau == null);
                while (sehelper.SimplifyStackVarsStatement(root, setReorderedIfs, ssa, cl))
                {
                    found = true;
                }
                SetVersionsToNull(root);
                SequenceHelper.CondenseSequences(root);
                ssau = new SSAUConstructorSparseEx();
                ssau.SplitVariables(root, mt);
                if (IterateStatements(root, ssau))
                {
                    found = true;
                }
                SetVersionsToNull(root);
                if (!found)
                {
                    break;
                }
            }
            // remove unused assignments
            ssau = new SSAUConstructorSparseEx();
            ssau.SplitVariables(root, mt);
            IterateStatements(root, ssau);
            SetVersionsToNull(root);
        }