Browse Source

Remove MyBlockStatement.

pull/1/head^2
David Srbecký 18 years ago
parent
commit
479918e7bc
  1. 1
      Decompiler.csproj
  2. 2
      lib/cecil-0.6/src/Mono.Cecil/Mono.Cecil.csproj
  3. 14
      src/AstMetodBodyBuilder.cs
  4. 53
      src/MyAst/MyBlockStatement.cs
  5. 2
      src/Transforms/Ast/RemoveEmptyElseBody.cs

1
Decompiler.csproj

@ -52,7 +52,6 @@ @@ -52,7 +52,6 @@
<Compile Include="src\ControlFlow\Node-Structure.cs" />
<Compile Include="src\MainForm.cs" />
<Compile Include="src\MainForm.Designer.cs" />
<Compile Include="src\MyAst\MyBlockStatement.cs" />
<Compile Include="src\MyAst\MyGotoStatement.cs" />
<Compile Include="src\MyAst\MyLabelStatement.cs" />
<Compile Include="src\Options.cs" />

2
lib/cecil-0.6/src/Mono.Cecil/Mono.Cecil.csproj

@ -375,4 +375,4 @@ @@ -375,4 +375,4 @@
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
</Project>
</Project>

14
src/AstMetodBodyBuilder.cs

@ -18,16 +18,16 @@ namespace Decompiler @@ -18,16 +18,16 @@ namespace Decompiler
static Dictionary<string, Cecil.TypeReference> localVarTypes = new Dictionary<string, Cecil.TypeReference>();
static Dictionary<string, bool> localVarDefined = new Dictionary<string, bool>();
public static MyBlockStatement CreateMetodBody(MethodDefinition methodDef)
public static BlockStatement CreateMetodBody(MethodDefinition methodDef)
{
AstMetodBodyBuilder builder = new AstMetodBodyBuilder();
builder.methodDef = methodDef;
return builder.CreateMetodBody();
}
public MyBlockStatement CreateMetodBody()
public BlockStatement CreateMetodBody()
{
Ast.MyBlockStatement astBlock = new Ast.MyBlockStatement();
Ast.BlockStatement astBlock = new Ast.BlockStatement();
methodDef.Body.Simplify();
@ -89,11 +89,11 @@ namespace Decompiler @@ -89,11 +89,11 @@ namespace Decompiler
yield return Ast.MyGotoStatement.Create(node, fallThroughNode);
}
} else if (node is AcyclicGraph) {
Ast.MyBlockStatement blockStatement = new Ast.MyBlockStatement();
Ast.BlockStatement blockStatement = new Ast.BlockStatement();
blockStatement.Children.AddRange(TransformNodes(node.Childs));
yield return blockStatement;
} else if (node is Loop) {
Ast.MyBlockStatement blockStatement = new Ast.MyBlockStatement();
Ast.BlockStatement blockStatement = new Ast.BlockStatement();
blockStatement.Children.AddRange(TransformNodes(node.Childs));
yield return new Ast.ForStatement(
null,
@ -119,7 +119,7 @@ namespace Decompiler @@ -119,7 +119,7 @@ namespace Decompiler
// Swap the method bodies
ifElseStmt.Condition = new Ast.UnaryOperatorExpression(new Ast.ParenthesizedExpression(ifElseStmt.Condition), UnaryOperatorType.Not);
Ast.MyBlockStatement trueBlock = new Ast.MyBlockStatement();
Ast.BlockStatement trueBlock = new Ast.BlockStatement();
// The block entry code
trueBlock.Children.Add(Ast.MyGotoStatement.Create(node, conditionalNode.Condition.FallThroughBasicBlock));
// Sugested content
@ -127,7 +127,7 @@ namespace Decompiler @@ -127,7 +127,7 @@ namespace Decompiler
ifElseStmt.TrueStatement.Add(trueBlock);
trueBlock.Parent = ifElseStmt;
Ast.MyBlockStatement falseBlock = new Ast.MyBlockStatement();
Ast.BlockStatement falseBlock = new Ast.BlockStatement();
// The block entry code
falseBlock.Children.Add(oldTrueBody);
// Sugested content

53
src/MyAst/MyBlockStatement.cs

@ -1,53 +0,0 @@ @@ -1,53 +0,0 @@
using System;
using System.Collections.Generic;
using Ast = ICSharpCode.NRefactory.Ast;
using Decompiler.ControlFlow;
namespace ICSharpCode.NRefactory.Ast
{
public class MyBlockStatement: BlockStatement
{
ChildrenCollection wrapper;
public class ChildrenCollection: System.Collections.ObjectModel.Collection<INode>
{
MyBlockStatement myStmt;
public void AddRange(IEnumerable<INode> items)
{
foreach(INode node in items) {
Add(node);
}
}
protected override void InsertItem(int index, INode item)
{
item.Parent = myStmt;
base.InsertItem(index, item);
}
protected override void SetItem(int index, INode item)
{
item.Parent = myStmt;
base.SetItem(index, item);
}
public ChildrenCollection(MyBlockStatement myStmt, IList<INode> nodes): base(nodes)
{
this.myStmt = myStmt;
}
}
public new ChildrenCollection Children {
get {
return wrapper;
}
}
public MyBlockStatement()
{
this.wrapper = new ChildrenCollection(this, base.Children);
}
}
}

2
src/Transforms/Ast/RemoveEmptyElseBody.cs

@ -25,7 +25,7 @@ namespace Decompiler.Transforms.Ast @@ -25,7 +25,7 @@ namespace Decompiler.Transforms.Ast
{
base.VisitIfElseStatement(ifElseStatement, data);
if (ifElseStatement.FalseStatement.Count == 1 &&
ifElseStatement.FalseStatement[0] is MyBlockStatement &&
ifElseStatement.FalseStatement[0] is BlockStatement &&
ifElseStatement.FalseStatement[0].Children.Count == 0)
{
ifElseStatement.FalseStatement.Clear();

Loading…
Cancel
Save