From 35fcc443e63607d631fe30861568b31fa46df451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Srbeck=C3=BD?= Date: Mon, 29 Oct 2007 19:57:39 +0000 Subject: [PATCH] Tweaks in the format of the output (place an empty line between commands) --- src/CodeDomBuilder.cs | 25 +++++++++++++++++++++++++ src/CodeDomMetodBodyBuilder.cs | 11 ++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/CodeDomBuilder.cs b/src/CodeDomBuilder.cs index f92713e22..5770093aa 100644 --- a/src/CodeDomBuilder.cs +++ b/src/CodeDomBuilder.cs @@ -37,6 +37,31 @@ namespace Decompiler code = code.Remove(0, code.IndexOf("\r\n") + "\r\n".Length); } + // Post processing commands + while(true) { + int endIndex = code.IndexOf("[JoinLine]") + "[JoinLine]".Length; + if (endIndex != -1) { + int startIndex = code.LastIndexOf("\r\n", endIndex, endIndex); + if (startIndex != -1) { + code = code.Remove(startIndex, endIndex - startIndex); + continue; + } + } + break; + } + while(true) { + int endIndex = code.IndexOf("[Tab]"); + if (endIndex != -1) { + int startIndex = code.LastIndexOf("\r\n", endIndex, endIndex); + if (startIndex != -1) { + code = code.Remove(endIndex, "[Tab]".Length); + code = code.Insert(endIndex, new string(' ', 40 - endIndex + startIndex)); + continue; + } + } + break; + } + return code; } diff --git a/src/CodeDomMetodBodyBuilder.cs b/src/CodeDomMetodBodyBuilder.cs index 02e3d86cd..a090c218e 100644 --- a/src/CodeDomMetodBodyBuilder.cs +++ b/src/CodeDomMetodBodyBuilder.cs @@ -17,16 +17,15 @@ namespace Decompiler foreach(Instruction instr in methodDef.Body.Instructions) { OpCode opCode = instr.OpCode; string decription = - string.Format("IL_{0:X2}: {1, -11} {2, -15} # {3}->{4} {5} {6}", + string.Format("IL_{0:X2}: {1, -22} # {2}->{3} {4} {5}", instr.Offset, - opCode, - FormatInstructionOperand(instr.Operand), + opCode + " " + FormatInstructionOperand(instr.Operand), opCode.StackBehaviourPop, opCode.StackBehaviourPush, opCode.FlowControl == FlowControl.Next ? string.Empty : "Flow=" + opCode.FlowControl, opCode.OpCodeType == OpCodeType.Macro ? "(macro)" : string.Empty); - codeStmtCol.Add(new CodeCommentStatement(decription)); + codeStmtCol.Add(new CodeCommentStatement(decription)); try { object codeExpr = MakeCodeDomExpression( instr, @@ -39,7 +38,9 @@ namespace Decompiler codeStmtCol.Add((CodeExpression)codeExpr); } } catch (NotImplementedException) { + codeStmtCol.Add(new CodeSnippetExpression("/* Not implemented */")); } + codeStmtCol.Add(new CodeSnippetStatement("")); } return codeStmtCol; @@ -251,7 +252,7 @@ namespace Decompiler case Code.Mkrefany: throw new NotImplementedException(); case Code.Newobj: throw new NotImplementedException(); case Code.No: throw new NotImplementedException(); - case Code.Nop: return new CodeCommentStatement("No-op"); + case Code.Nop: return new CodeSnippetExpression("/* No-op */"); case Code.Or: throw new NotImplementedException(); case Code.Pop: throw new NotImplementedException(); case Code.Readonly: throw new NotImplementedException();