示例#1
0
        static void DumpMethod(SourcePawnFile file, SourceBuilder source, uint addr)
        {
            MethodParser mp    = new MethodParser(file, addr);
            LGraph       graph = mp.parse();

            NodeBuilder nb = new NodeBuilder(file, graph);

            NodeBlock[] nblocks = nb.buildNodes();

            NodeGraph ngraph = new NodeGraph(file, nblocks);

            // Remove dead phis first.
            NodeAnalysis.RemoveDeadCode(ngraph);

            NodeRewriter rewriter = new NodeRewriter(ngraph);

            rewriter.rewrite();

            NodeAnalysis.CollapseArrayReferences(ngraph);

            // Propagate type information.
            ForwardTypePropagation ftypes = new ForwardTypePropagation(ngraph);

            ftypes.propagate();

            BackwardTypePropagation btypes = new BackwardTypePropagation(ngraph);

            btypes.propagate();

            // We're not fixpoint, so just iterate again.
            ftypes.propagate();
            btypes.propagate();

            // Try this again now that we have type information.
            NodeAnalysis.CollapseArrayReferences(ngraph);

            ftypes.propagate();
            btypes.propagate();

            // Coalesce x[y] = x[y] + 5 into x[y] += 5
            NodeAnalysis.CoalesceLoadStores(ngraph);

            // After this, it is not legal to run type analysis again, because
            // arguments expecting references may have been rewritten to take
            // constants, for pretty-printing.
            NodeAnalysis.AnalyzeHeapUsage(ngraph);

            // Do another DCE pass, this time, without guards.
            NodeAnalysis.RemoveGuards(ngraph);
            NodeAnalysis.RemoveDeadCode(ngraph);

            NodeRenamer renamer = new NodeRenamer(ngraph);

            renamer.rename();

            // Do a pass to coalesce declaration+stores.
            NodeAnalysis.CoalesceLoadsAndDeclarations(ngraph);

            // Simplify conditional expressions.
            // BlockAnalysis.NormalizeConditionals(ngraph);
            var sb        = new SourceStructureBuilder(ngraph);
            var structure = sb.build();

            source.write(structure);

            //System.Console.In.Read();
            //System.Console.In.Read();
        }
示例#2
0
文件: Lysis.cs 项目: not1ce111/Spedit
        static void DumpMethod(SourcePawnFile file, SourceBuilder source, uint addr)
        {
            MethodParser mp = new MethodParser(file, addr);
            LGraph graph = mp.parse();

            NodeBuilder nb = new NodeBuilder(file, graph);
            NodeBlock[] nblocks = nb.buildNodes();

            NodeGraph ngraph = new NodeGraph(file, nblocks);

            // Remove dead phis first.
            NodeAnalysis.RemoveDeadCode(ngraph);

            NodeRewriter rewriter = new NodeRewriter(ngraph);
            rewriter.rewrite();

            NodeAnalysis.CollapseArrayReferences(ngraph);

            // Propagate type information.
            ForwardTypePropagation ftypes = new ForwardTypePropagation(ngraph);
            ftypes.propagate();

            BackwardTypePropagation btypes = new BackwardTypePropagation(ngraph);
            btypes.propagate();

            // We're not fixpoint, so just iterate again.
            ftypes.propagate();
            btypes.propagate();

            // Try this again now that we have type information.
            NodeAnalysis.CollapseArrayReferences(ngraph);

            ftypes.propagate();
            btypes.propagate();

            // Coalesce x[y] = x[y] + 5 into x[y] += 5
            NodeAnalysis.CoalesceLoadStores(ngraph);

            // After this, it is not legal to run type analysis again, because
            // arguments expecting references may have been rewritten to take
            // constants, for pretty-printing.
            NodeAnalysis.AnalyzeHeapUsage(ngraph);

            // Do another DCE pass, this time, without guards.
            NodeAnalysis.RemoveGuards(ngraph);
            NodeAnalysis.RemoveDeadCode(ngraph);

            NodeRenamer renamer = new NodeRenamer(ngraph);
            renamer.rename();

            // Do a pass to coalesce declaration+stores.
            NodeAnalysis.CoalesceLoadsAndDeclarations(ngraph);

            // Simplify conditional expressions.
            // BlockAnalysis.NormalizeConditionals(ngraph);
            var sb = new SourceStructureBuilder(ngraph);
            var structure = sb.build();

            source.write(structure);

            //System.Console.In.Read();
            //System.Console.In.Read();
        }