Write() public method

public Write ( Procedure proc ) : void
proc Procedure
return void
Exemplo n.º 1
0
        public void DisplayProcedure(Procedure proc)
        {
            if (codeView == null || proc == null)
                return;

            this.proc = proc;
            var tsf = new TextSpanFormatter();
            var fmt = new CodeFormatter(tsf);
            fmt.InnerFormatter.UseTabs = false;
            fmt.Write(proc);
            this.TextView.Model = tsf.GetModel();
        }
Exemplo n.º 2
0
        private void RunTest(ProcedureBuilder mock, string outFilename)
        {
            Procedure proc = mock.Procedure;
            using (FileUnitTester fut = new FileUnitTester(outFilename))
            {
                ControlFlowGraphCleaner cfgc = new ControlFlowGraphCleaner(proc);
                cfgc.Transform();
                proc.Write(false, fut.TextWriter);
                fut.TextWriter.WriteLine();

                var sa = new Reko.Structure.Schwartz.ProcedureStructurer(proc);
                sa.Structure();
                CodeFormatter fmt = new CodeFormatter(new TextFormatter(fut.TextWriter));
                fmt.Write(proc);
                fut.TextWriter.WriteLine("===========================");

                fut.AssertFilesEqual();
            }
        }
Exemplo n.º 3
0
        private void RunTest(ProcedureBuilder mock, string outFilename)
        {
            Procedure proc = mock.Procedure;
            using (FileUnitTester fut = new FileUnitTester(outFilename))
            {
                ControlFlowGraphCleaner cfgc = new ControlFlowGraphCleaner(proc);
                cfgc.Transform();
                proc.Write(false, fut.TextWriter);
                fut.TextWriter.WriteLine();

                var sa = new StructureAnalysis(new FakeDecompilerEventListener(), program, proc);
                sa.Structure();
                CodeFormatter fmt = new CodeFormatter(new TextFormatter(fut.TextWriter));
                fmt.Write(proc);
                fut.TextWriter.WriteLine("===========================");

                fut.AssertFilesEqual();
            }
        }
Exemplo n.º 4
0
        private void RunTest16(string sourceFilename, string outFilename, Address addrBase)
        {
            using (FileUnitTester fut = new FileUnitTester(outFilename))
            {
                RewriteProgramMsdos(sourceFilename, addrBase);
                foreach (Procedure proc in program.Procedures.Values)
                {
                    var cfgc = new ControlFlowGraphCleaner(program.Procedures.Values[0]);
                    cfgc.Transform();
                    proc.Write(false, fut.TextWriter);
                    fut.TextWriter.WriteLine();

                    var sa = new Reko.Structure.Schwartz.ProcedureStructurer(proc);
                    sa.Structure();
                    var fmt = new CodeFormatter(new TextFormatter(fut.TextWriter));
                    fmt.Write(proc);
                    fut.TextWriter.WriteLine("===========================");
                }
                fut.AssertFilesEqual();
            }
        }
Exemplo n.º 5
0
 public void CopyAll()
 {
     if (this.proc == null)
         return;
     var sw = new StringWriter();
     var writer = new TextFormatter(sw);
     var fmt = new CodeFormatter(writer);
     fmt.Write(proc);
     sw.Flush();
     Clipboard.SetText(sw.ToString());
 }
Exemplo n.º 6
0
 private void RunTest32(string expected, Program program)
 {
     var sw = new StringWriter();
     foreach (var proc in program.Procedures.Values)
     {
         var cfgc = new ControlFlowGraphCleaner(proc);
         cfgc.Transform();
         var sa = new Reko.Structure.Schwartz.ProcedureStructurer(proc);
         sa.Structure();
         var fmt = new CodeFormatter(new TextFormatter(sw));
         fmt.Write(proc);
         sw.WriteLine("===");
     }
     Console.WriteLine(sw);
     Assert.AreEqual(expected, sw.ToString());
 }
Exemplo n.º 7
0
        private void RunTest32(string sourceFilename, string outFilename, Address addrBase)
        {
            var program = RewriteProgram32(sourceFilename, addrBase);
            using (FileUnitTester fut = new FileUnitTester(outFilename))
            {
                foreach (Procedure proc in program.Procedures.Values)
                {
                    var cfgc = new ControlFlowGraphCleaner(program.Procedures.Values[0]);
                    cfgc.Transform();
                    proc.Write(false, fut.TextWriter);
                    fut.TextWriter.WriteLine();

                    var sa = new StructureAnalysis(new FakeDecompilerEventListener(), program, proc);
                    sa.Structure();
                    var fmt = new CodeFormatter(new TextFormatter(fut.TextWriter));
                    fmt.Write(proc);
                    fut.TextWriter.WriteLine("===========================");
                }
                fut.AssertFilesEqual();
            }
        }
Exemplo n.º 8
0
 private void RunTest(string expected, Program program)
 {
     var sw = new StringWriter();
     foreach (var proc in program.Procedures.Values)
     {
         var cfgc = new ControlFlowGraphCleaner(proc);
         cfgc.Transform();
         var sa = new StructureAnalysis(new FakeDecompilerEventListener(), program, proc);
         sa.Structure();
         var fmt = new CodeFormatter(new TextFormatter(sw));
         fmt.Write(proc);
         sw.WriteLine("===");
     }
     Console.WriteLine(sw);
     Assert.AreEqual(expected, sw.ToString());
 }
Exemplo n.º 9
0
 public void WriteDecompiledProcedures(Program program, TextWriter w)
 {
     WriteHeaderComment(Path.GetFileName(program.OutputFilename), program, w);
     w.WriteLine("#include \"{0}\"", Path.GetFileName(program.TypesFilename));
     w.WriteLine();
     var fmt = new CodeFormatter(new TextFormatter(w));
     foreach (Procedure proc in program.Procedures.Values)
     {
         try
         {
             fmt.Write(proc);
             w.WriteLine();
         }
         catch (Exception ex)
         {
             w.WriteLine();
             w.WriteLine("// Exception {0} when writing procedure.", ex.Message);
         }
     }
 }