Browse Source

Remove unnecessary labels

pull/1/head^2
David Srbecký 18 years ago
parent
commit
9d82c6c55b
  1. 4
      src/AstMetodBodyBuilder.cs
  2. 14
      src/StackAnalysis.cs

4
src/AstMetodBodyBuilder.cs

@ -68,7 +68,9 @@ namespace Decompiler @@ -68,7 +68,9 @@ namespace Decompiler
astStatement = MakeComment(description);
}
//astBlock.Children.Add(MakeComment(description));
astBlock.Children.Add(new Ast.LabelStatement(string.Format("IL_{0:X2}", instr.Offset)));
if (stackAnalysis.BranchTargetOf[instr].Count > 0) {
astBlock.Children.Add(new Ast.LabelStatement(string.Format("IL_{0:X2}", instr.Offset)));
}
astBlock.Children.Add(astStatement);
//astBlock.Children.Add(MakeComment(" " + stackAnalysis.StackAfter[instr].ToString()));
}

14
src/StackAnalysis.cs

@ -108,6 +108,7 @@ namespace Decompiler @@ -108,6 +108,7 @@ namespace Decompiler
MethodDefinition methodDef;
Dictionary<Instruction, CilStack> stackBefore = new Dictionary<Instruction, CilStack>();
Dictionary<Instruction, CilStack> stackAfter = new Dictionary<Instruction, CilStack>();
Dictionary<Instruction, List<Instruction>> branchTargetOf = new Dictionary<Instruction, List<Instruction>>();
public Dictionary<Instruction, CilStack> StackBefore {
get { return stackBefore; }
@ -117,6 +118,10 @@ namespace Decompiler @@ -117,6 +118,10 @@ namespace Decompiler
get { return stackAfter; }
}
public Dictionary<Instruction, List<Instruction>> BranchTargetOf {
get { return branchTargetOf; }
}
public Cecil.TypeReference GetTypeOf(Instruction inst)
{
if (Util.GetNumberOfOutputs(methodDef, inst) == 0) {
@ -132,6 +137,15 @@ namespace Decompiler @@ -132,6 +137,15 @@ namespace Decompiler
foreach(Instruction inst in methodDef.Body.Instructions) {
stackBefore[inst] = null;
stackAfter[inst] = null;
branchTargetOf[inst] = new List<Instruction>();
}
foreach(Instruction inst in methodDef.Body.Instructions) {
if (inst.OpCode.FlowControl == FlowControl.Branch ||
inst.OpCode.FlowControl == FlowControl.Cond_Branch)
{
branchTargetOf[(Instruction)inst.Operand].Add(inst);
}
}
if (methodDef.Body.Instructions.Count > 0) {

Loading…
Cancel
Save