private void UpdateText()
{
if (PcListBox.SelectedItem != null)
{
var PCItem = (PCItem)PcListBox.SelectedItem;
var MethodCacheInfo = PCItem.MethodCacheInfo;
var MinPC = MethodCacheInfo.MinPC;
var MaxPC = MethodCacheInfo.MaxPC;
var Memory = CpuProcessor.Memory;
AstNodeStm Node = null;
if (MethodCacheInfo.AstTree != null) Node = MethodCacheInfo.AstTree.Optimize(CpuProcessor);
var InfoLines = new List<string>();
InfoLines.Add(String.Format("Name: {0}", MethodCacheInfo.Name));
InfoLines.Add(String.Format("TotalInstructions: {0}", MethodCacheInfo.TotalInstructions));
InfoLines.Add(String.Format("DisableOptimizations: {0}", MethodCacheInfo.DynarecFunction.DisableOptimizations));
InfoLines.Add(String.Format("EntryPC: 0x{0:X8}", MethodCacheInfo.EntryPC));
InfoLines.Add(String.Format("MinPC: 0x{0:X8}", MethodCacheInfo.MinPC));
InfoLines.Add(String.Format("MaxPC: 0x{0:X8}", MethodCacheInfo.MaxPC));
InfoLines.Add(String.Format("TimeAnalyzeBranches: {0}", MethodCacheInfo.DynarecFunction.TimeAnalyzeBranches.TotalMilliseconds));
InfoLines.Add(String.Format("TimeGenerateAst: {0}", MethodCacheInfo.DynarecFunction.TimeGenerateAst.TotalMilliseconds));
InfoLines.Add(String.Format("TimeOptimize: {0}", MethodCacheInfo.DynarecFunction.TimeOptimize.TotalMilliseconds));
InfoLines.Add(String.Format("TimeGenerateIL: {0}", MethodCacheInfo.DynarecFunction.TimeGenerateIL.TotalMilliseconds));
InfoLines.Add(String.Format("TimeCreateDelegate: {0}", MethodCacheInfo.DynarecFunction.TimeCreateDelegate.TotalMilliseconds));
InfoLines.Add(String.Format("TimeLinking: {0}", MethodCacheInfo.DynarecFunction.TimeLinking.TotalMilliseconds));
InfoLines.Add(String.Format("TimeTotal: {0}", MethodCacheInfo.DynarecFunction.TimeTotal.TotalMilliseconds));
InfoLines.Add(String.Format(""));
foreach (var Item in MethodCacheInfo.DynarecFunction.InstructionStats.OrderBy(Pair => Pair.Value))
{
InfoLines.Add(String.Format("{0}: {1}", Item.Key, Item.Value));
}
InfoTextBox.Text = String.Join("\r\n", InfoLines);
var OutString = "";
switch (LanguageComboBox.SelectedItem.ToString())
{
case "C#":
if (Node != null)
{
OutString = Node.ToCSharpString().Replace("CpuThreadState.", "");
}
break;
case "IL":
if (Node != null)
{
OutString = Node.ToILString<Action<CpuThreadState>>();
}
break;
case "Ast":
if (Node != null)
{
OutString = AstSerializer.SerializeAsXml(Node);
}
break;
case "Mips":
{
var MipsDisassembler = new MipsDisassembler();
try
{
for (uint PC = MinPC; PC <= MaxPC; PC += 4)
{
var Instruction = Memory.ReadSafe<Instruction>(PC);
var Result = MipsDisassembler.Disassemble(PC, Instruction);
OutString += String.Format("0x{0:X8}: {1}\r\n", PC, Result.ToString());
}
}
catch (Exception Exception)
{
Console.Error.WriteLine(Exception);
}
}
break;
default:
break;
}
ViewTextBox.Text = OutString.Replace("\n", "\r\n");
}
}