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

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

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

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

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

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

@ -77,13 +77,13 @@ namespace Decompiler.Transforms @@ -77,13 +77,13 @@ namespace Decompiler.Transforms
}
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,
new NullReferenceExpression()
);
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,
new NullReferenceExpression()
);

9
ILSpy.sln

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.0.1.7096
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy", "ILSpy\ILSpy.csproj", "{1E85EFF9-E370-4683-83E4-8A3D063FF791}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TreeView", "SharpTreeView\ICSharpCode.TreeView.csproj", "{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}"
@ -39,13 +40,13 @@ Global @@ -39,13 +40,13 @@ Global
{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.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|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}.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|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
{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

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

@ -177,7 +177,7 @@ namespace Mono.Cecil { @@ -177,7 +177,7 @@ namespace Mono.Cecil {
{
return module.HasImage ()
? 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 @@ -39,11 +39,21 @@ namespace ICSharpCode.NRefactory.CSharp.PatternMatching
return p != null ? new ExpressionPlaceholder(p) : null;
}
public Expression ToExpression()
{
return new ExpressionPlaceholder(this);
}
public static implicit operator Statement(Pattern p)
{
return p != null ? new StatementPlaceholder(p) : null;
}
public Statement ToStatement()
{
return new StatementPlaceholder(this);
}
public static implicit operator BlockStatement(Pattern p)
{
return p != null ? new BlockStatementPlaceholder(p) : null;

Loading…
Cancel
Save