private void RunTest(string sExp, Procedure proc)
 {
     var ps = new ProcedureStructurer(proc);
     var reg = ps.Execute();
     var sb = new StringWriter();
     reg.Write(sb);
     sb.GetStringBuilder().Replace("\t", "    ");
     var s = sb.ToString();
     if (sExp != s)
     {
         Debug.WriteLine(s);
         Assert.AreEqual(sExp, s);
     }
 }
Example #2
0
        /// <summary>
        /// Extracts structured program constructs out of snarled goto nests, if possible.
        /// Since procedures are now independent of each other, this analysis
        /// is done one procedure at a time.
        /// </summary>
        public void StructureProgram()
		{
            foreach (var program in project.Programs)
            {
                int i = 0;

                foreach (Procedure proc in program.Procedures.Values)
                {
                    try
                    {
                        eventListener.ShowProgress("Rewriting procedures to high-level language.", i, program.Procedures.Values.Count);
                        ++i;
                        Console.WriteLine("rewriting: {0}", proc);
                        IStructureAnalysis sa = new Structure.Schwartz.ProcedureStructurer(proc);
                        sa.Structure();
                    }
                    catch (Exception e)
                    {
                        eventListener.Error(
                            eventListener.CreateProcedureNavigator(proc),
                            e,
                            "An error occurred while rewriting procedure to high-level language.");
                    }
                }
                WriteDecompilerProducts();
            }
			eventListener.ShowStatus("Rewriting complete.");
		}