Exemplo n.º 1
0
        public static bool Parse(AMethodDecl method)
        {
            StatementRemover remover = new StatementRemover();

            method.Apply(remover);
            return(remover.changedSomething);
        }
Exemplo n.º 2
0
        public override void CaseAMethodDecl(AMethodDecl node)
        {
            if (data.AllowPrintouts)
            {
                Form1.Form.SetStatusText(prefix + " [" + ++methodNr + "/" + methodCount + " " + node.GetName().Text + "]");
            }
            if (node.GetName().Text.Contains("t2"))
            {
                node = node;
            }
            //Move locals to the start
            node.Apply(new MoveLocalsToStart(finalTrans.data));
            bool changes = true;

            while (changes)
            {
                changes = false;

                //Remove foo = foo
                RemoveSelfAssignments.Parse(node, data);

                //Create cfg
                ControlFlowGraph cfg = ControlFlowGraph.Create(node);
                RemoveDeadCode.Parse(cfg);
                LivenessAnalysis.CalculateLiveVariables(cfg, data);
                bool redoLivenessAnalysis;
                changes |= RemoveUnusedAssignments.Parse(cfg, data, out redoLivenessAnalysis);
                if (redoLivenessAnalysis)
                {
                    LivenessAnalysis.CalculateLiveVariables(cfg, data);
                }
                changes |= VariableJoiner.Parse(cfg, data);
                //This phase doesn't use liveness analysis
                changes |= RemoveUnusedLocals.Parse(cfg, data);


                while (true)
                {
                    bool changed = RemoveSingleUsedAssignments.Parse(cfg, data);
                    if (changed)
                    {
                        changes = true;
                        LivenessAnalysis.CalculateLiveVariables(cfg, data);
                        continue;
                    }
                    break;
                }


                changes |= StatementRemover.Parse(node);
            }
        }
 public static bool Parse(AMethodDecl method)
 {
     StatementRemover remover = new StatementRemover();
     method.Apply(remover);
     return remover.changedSomething;
 }