Browse Source

Adjust ILSpy to NRefactory changes.

pull/70/head
Daniel Grunwald 14 years ago
parent
commit
d80719c4ee
  1. 4
      ICSharpCode.Decompiler/Ast/DeclareVariableInSmallestScope.cs
  2. 4
      ICSharpCode.Decompiler/Ast/Transforms/DelegateConstruction.cs
  3. 50
      ICSharpCode.Decompiler/Ast/Transforms/PatternStatementTransform.cs
  4. 4
      ICSharpCode.Decompiler/Ast/Transforms/PushNegation.cs
  5. 9
      ILSpy.sln
  6. 2
      Mono.Cecil/Mono.Cecil/SecurityDeclaration.cs
  7. 10
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/PatternMatching/Pattern.cs

4
ICSharpCode.Decompiler/Ast/DeclareVariableInSmallestScope.cs

@ -15,8 +15,8 @@ namespace Decompiler
{ {
static readonly ExpressionStatement assignmentPattern = new ExpressionStatement( static readonly ExpressionStatement assignmentPattern = new ExpressionStatement(
new AssignmentExpression( new AssignmentExpression(
new NamedNode("ident", new IdentifierExpression()).ToExpression(), new NamedNode("ident", new IdentifierExpression()),
new AnyNode("init").ToExpression() new AnyNode("init")
)); ));
/// <summary> /// <summary>

4
ICSharpCode.Decompiler/Ast/Transforms/DelegateConstruction.cs

@ -196,8 +196,8 @@ namespace Decompiler.Transforms
// "variableName.MemberName = right;" // "variableName.MemberName = right;"
ExpressionStatement closureFieldAssignmentPattern = new ExpressionStatement( ExpressionStatement closureFieldAssignmentPattern = new ExpressionStatement(
new AssignmentExpression( new AssignmentExpression(
new NamedNode("left", new MemberReferenceExpression { Target = new IdentifierExpression(variable.Name) }).ToExpression(), new NamedNode("left", new MemberReferenceExpression { Target = new IdentifierExpression(variable.Name) }),
new AnyNode("right").ToExpression() new AnyNode("right")
) )
); );
Match m = closureFieldAssignmentPattern.Match(cur); Match m = closureFieldAssignmentPattern.Match(cur);

50
ICSharpCode.Decompiler/Ast/Transforms/PatternStatementTransform.cs

@ -26,14 +26,14 @@ namespace Decompiler.Transforms
/// $type $variable = $initializer; /// $type $variable = $initializer;
/// </summary> /// </summary>
static readonly AstNode variableDeclPattern = new VariableDeclarationStatement { static readonly AstNode variableDeclPattern = new VariableDeclarationStatement {
Type = new AnyNode("type").ToType(), Type = new AnyNode("type"),
Variables = { Variables = {
new NamedNode( new NamedNode(
"variable", "variable",
new VariableInitializer { new VariableInitializer {
Initializer = new AnyNode("initializer").ToExpression() Initializer = new AnyNode("initializer")
} }
).ToVariable() )
} }
}; };
@ -41,7 +41,7 @@ namespace Decompiler.Transforms
/// Variable declaration without initializer. /// Variable declaration without initializer.
/// </summary> /// </summary>
static readonly AstNode simpleVariableDefinition = new VariableDeclarationStatement { static readonly AstNode simpleVariableDefinition = new VariableDeclarationStatement {
Type = new AnyNode().ToType(), Type = new AnyNode(),
Variables = { Variables = {
new VariableInitializer() // any name but no initializer new VariableInitializer() // any name but no initializer
} }
@ -49,7 +49,7 @@ namespace Decompiler.Transforms
#region using #region using
static readonly AstNode usingTryCatchPattern = new TryCatchStatement { static readonly AstNode usingTryCatchPattern = new TryCatchStatement {
TryBlock = new AnyNode("body").ToBlock(), TryBlock = new AnyNode("body"),
FinallyBlock = new BlockStatement { FinallyBlock = new BlockStatement {
new Choice { new Choice {
{ "valueType", { "valueType",
@ -58,7 +58,7 @@ namespace Decompiler.Transforms
{ "referenceType", { "referenceType",
new IfElseStatement { new IfElseStatement {
Condition = new BinaryOperatorExpression( Condition = new BinaryOperatorExpression(
new NamedNode("ident", new IdentifierExpression()).ToExpression(), new NamedNode("ident", new IdentifierExpression()),
BinaryOperatorType.InEquality, BinaryOperatorType.InEquality,
new NullReferenceExpression() new NullReferenceExpression()
), ),
@ -102,14 +102,14 @@ namespace Decompiler.Transforms
#region foreach #region foreach
UsingStatement foreachPattern = new UsingStatement { UsingStatement foreachPattern = new UsingStatement {
ResourceAcquisition = new VariableDeclarationStatement { ResourceAcquisition = new VariableDeclarationStatement {
Type = new AnyNode("enumeratorType").ToType(), Type = new AnyNode("enumeratorType"),
Variables = { Variables = {
new NamedNode( new NamedNode(
"enumeratorVariable", "enumeratorVariable",
new VariableInitializer { new VariableInitializer {
Initializer = new AnyNode("collection").ToExpression().Invoke("GetEnumerator") Initializer = new AnyNode("collection").ToExpression().Invoke("GetEnumerator")
} }
).ToVariable() )
} }
}, },
EmbeddedStatement = new Choice { EmbeddedStatement = new Choice {
@ -123,14 +123,14 @@ namespace Decompiler.Transforms
Condition = new IdentifierExpressionBackreference("enumeratorVariable").ToExpression().Invoke("MoveNext"), Condition = new IdentifierExpressionBackreference("enumeratorVariable").ToExpression().Invoke("MoveNext"),
EmbeddedStatement = new BlockStatement { EmbeddedStatement = new BlockStatement {
new VariableDeclarationStatement { new VariableDeclarationStatement {
Type = new AnyNode("itemType").ToType(), Type = new AnyNode("itemType"),
Variables = { Variables = {
new NamedNode( new NamedNode(
"itemVariable", "itemVariable",
new VariableInitializer { new VariableInitializer {
Initializer = new IdentifierExpressionBackreference("enumeratorVariable").ToExpression().Member("Current") Initializer = new IdentifierExpressionBackreference("enumeratorVariable").ToExpression().Member("Current")
} }
).ToVariable() )
} }
}, },
new Repeat(new AnyNode("statement")).ToStatement() new Repeat(new AnyNode("statement")).ToStatement()
@ -141,16 +141,16 @@ namespace Decompiler.Transforms
{ "itemVariableOutsideLoop", { "itemVariableOutsideLoop",
new BlockStatement { new BlockStatement {
new VariableDeclarationStatement { new VariableDeclarationStatement {
Type = new AnyNode("itemType").ToType(), Type = new AnyNode("itemType"),
Variables = { Variables = {
new NamedNode("itemVariable", new VariableInitializer()).ToVariable() new NamedNode("itemVariable", new VariableInitializer())
} }
}, },
new WhileStatement { new WhileStatement {
Condition = new IdentifierExpressionBackreference("enumeratorVariable").ToExpression().Invoke("MoveNext"), Condition = new IdentifierExpressionBackreference("enumeratorVariable").ToExpression().Invoke("MoveNext"),
EmbeddedStatement = new BlockStatement { EmbeddedStatement = new BlockStatement {
new AssignmentExpression { new AssignmentExpression {
Left = new IdentifierExpressionBackreference("itemVariable").ToExpression(), Left = new IdentifierExpressionBackreference("itemVariable"),
Operator = AssignmentOperatorType.Assign, Operator = AssignmentOperatorType.Assign,
Right = new IdentifierExpressionBackreference("enumeratorVariable").ToExpression().Member("Current") Right = new IdentifierExpressionBackreference("enumeratorVariable").ToExpression().Member("Current")
}, },
@ -191,20 +191,22 @@ namespace Decompiler.Transforms
#region for #region for
WhileStatement forPattern = new WhileStatement { WhileStatement forPattern = new WhileStatement {
Condition = new BinaryOperatorExpression { Condition = new BinaryOperatorExpression {
Left = new NamedNode("ident", new IdentifierExpression()).ToExpression(), Left = new NamedNode("ident", new IdentifierExpression()),
Operator = BinaryOperatorType.Any, Operator = BinaryOperatorType.Any,
Right = new AnyNode("endExpr").ToExpression() Right = new AnyNode("endExpr")
}, },
EmbeddedStatement = new BlockStatement { EmbeddedStatement = new BlockStatement {
new Repeat(new AnyNode("statement")).ToStatement(), Statements = {
new NamedNode( new Repeat(new AnyNode("statement")),
"increment", new NamedNode(
new ExpressionStatement( "increment",
new AssignmentExpression { new ExpressionStatement(
Left = new Backreference("ident").ToExpression(), new AssignmentExpression {
Operator = AssignmentOperatorType.Any, Left = new Backreference("ident"),
Right = new AnyNode().ToExpression() Operator = AssignmentOperatorType.Any,
})).ToStatement() Right = new AnyNode()
}))
}
} }
}; };

4
ICSharpCode.Decompiler/Ast/Transforms/PushNegation.cs

@ -77,13 +77,13 @@ namespace Decompiler.Transforms
} }
readonly static AstNode asCastIsNullPattern = new BinaryOperatorExpression( readonly static AstNode asCastIsNullPattern = new BinaryOperatorExpression(
new AnyNode("expr").ToExpression().CastAs(new AnyNode("type").ToType()), new AnyNode("expr").ToExpression().CastAs(new AnyNode("type")),
BinaryOperatorType.Equality, BinaryOperatorType.Equality,
new NullReferenceExpression() new NullReferenceExpression()
); );
readonly static AstNode asCastIsNotNullPattern = new BinaryOperatorExpression( readonly static AstNode asCastIsNotNullPattern = new BinaryOperatorExpression(
new AnyNode("expr").ToExpression().CastAs(new AnyNode("type").ToType()), new AnyNode("expr").ToExpression().CastAs(new AnyNode("type")),
BinaryOperatorType.InEquality, BinaryOperatorType.InEquality,
new NullReferenceExpression() new NullReferenceExpression()
); );

9
ILSpy.sln

@ -1,6 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 11.00 Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010 # Visual Studio 2010
# SharpDevelop 4.0.1.7096
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy", "ILSpy\ILSpy.csproj", "{1E85EFF9-E370-4683-83E4-8A3D063FF791}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy", "ILSpy\ILSpy.csproj", "{1E85EFF9-E370-4683-83E4-8A3D063FF791}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TreeView", "SharpTreeView\ICSharpCode.TreeView.csproj", "{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TreeView", "SharpTreeView\ICSharpCode.TreeView.csproj", "{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}"
@ -39,13 +40,13 @@ Global
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.Release|Any CPU.Build.0 = Release|Any CPU {DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.Release|Any CPU.Build.0 = Release|Any CPU
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.Release|x86.ActiveCfg = Release|Any CPU {DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.Release|x86.ActiveCfg = Release|Any CPU
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.Release|x86.Build.0 = Release|Any CPU {DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.Release|x86.Build.0 = Release|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|Any CPU.ActiveCfg = net_4_0_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|Any CPU.ActiveCfg = net_3_5_Debug|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|Any CPU.Build.0 = net_4_0_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|Any CPU.Build.0 = net_4_0_Debug|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|x86.ActiveCfg = net_4_0_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|x86.ActiveCfg = net_3_5_Debug|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|x86.Build.0 = net_2_0_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|x86.Build.0 = net_2_0_Debug|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|Any CPU.ActiveCfg = net_3_5_Release|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|Any CPU.Build.0 = net_4_0_Release|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|Any CPU.Build.0 = net_4_0_Release|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|x86.ActiveCfg = net_4_0_Release|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|x86.ActiveCfg = net_3_5_Release|Any CPU
{D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|x86.Build.0 = net_2_0_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|x86.Build.0 = net_2_0_Debug|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.Build.0 = Debug|Any CPU {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.Build.0 = Debug|Any CPU

2
Mono.Cecil/Mono.Cecil/SecurityDeclaration.cs

@ -177,7 +177,7 @@ namespace Mono.Cecil {
{ {
return module.HasImage () return module.HasImage ()
? module.Read (ref variable, self, (provider, reader) => reader.ReadSecurityDeclarations (provider)) ? module.Read (ref variable, self, (provider, reader) => reader.ReadSecurityDeclarations (provider))
: LazyInitializer.EnsureInitialized(ref variable); : variable = new Collection<SecurityDeclaration>();
} }
} }
} }

10
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/PatternMatching/Pattern.cs

@ -39,11 +39,21 @@ namespace ICSharpCode.NRefactory.CSharp.PatternMatching
return p != null ? new ExpressionPlaceholder(p) : null; return p != null ? new ExpressionPlaceholder(p) : null;
} }
public Expression ToExpression()
{
return new ExpressionPlaceholder(this);
}
public static implicit operator Statement(Pattern p) public static implicit operator Statement(Pattern p)
{ {
return p != null ? new StatementPlaceholder(p) : null; return p != null ? new StatementPlaceholder(p) : null;
} }
public Statement ToStatement()
{
return new StatementPlaceholder(this);
}
public static implicit operator BlockStatement(Pattern p) public static implicit operator BlockStatement(Pattern p)
{ {
return p != null ? new BlockStatementPlaceholder(p) : null; return p != null ? new BlockStatementPlaceholder(p) : null;

Loading…
Cancel
Save