Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/icsharpcode/ILSpy into Debu…
Browse files Browse the repository at this point in the history
…gger
  • Loading branch information
eusebiu committed Mar 20, 2011
2 parents 6f29043 + 6a0d365 commit 858e6c0
Show file tree
Hide file tree
Showing 19 changed files with 891 additions and 337 deletions.
10 changes: 5 additions & 5 deletions ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class AstMethodBodyBuilder
TypeSystem typeSystem;
DecompilerContext context;
HashSet<ILVariable> localVariablesToDefine = new HashSet<ILVariable>(); // local variables that are missing a definition
HashSet<ILVariable> implicitlyDefinedVariables = new HashSet<ILVariable>(); // local variables that are implicitly defined (e.g. catch handler)

/// <summary>
/// Creates the body for the method definition.
Expand Down Expand Up @@ -89,8 +88,11 @@ join v in astBuilder.Parameters on p.Annotation<ParameterDefinition>() equals v.
context.CancellationToken.ThrowIfCancellationRequested();
Ast.BlockStatement astBlock = TransformBlock(ilMethod);
CommentStatement.ReplaceAll(astBlock); // convert CommentStatements to Comments
foreach (ILVariable v in localVariablesToDefine.Except(implicitlyDefinedVariables)) {
DeclareVariableInSmallestScope.DeclareVariable(astBlock, AstBuilder.ConvertType(v.Type), v.Name);

Statement insertionPoint = astBlock.Statements.FirstOrDefault();
foreach (ILVariable v in localVariablesToDefine) {
var newVarDecl = new VariableDeclarationStatement(AstBuilder.ConvertType(v.Type), v.Name);
astBlock.Statements.InsertBefore(insertionPoint, newVarDecl);
}

// store the variables - used for debugger
Expand Down Expand Up @@ -163,8 +165,6 @@ IEnumerable<Statement> TransformNode(ILNode node)
var tryCatchStmt = new Ast.TryCatchStatement();
tryCatchStmt.TryBlock = TransformBlock(tryCatchNode.TryBlock);
foreach (var catchClause in tryCatchNode.CatchBlocks) {
if (catchClause.ExceptionVariable != null)
implicitlyDefinedVariables.Add(catchClause.ExceptionVariable);
tryCatchStmt.CatchClauses.Add(
new Ast.CatchClause {
Type = AstBuilder.ConvertType(catchClause.ExceptionType),
Expand Down
91 changes: 0 additions & 91 deletions ICSharpCode.Decompiler/Ast/DeclareVariableInSmallestScope.cs

This file was deleted.

11 changes: 11 additions & 0 deletions ICSharpCode.Decompiler/Ast/NRefactoryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.CSharp.PatternMatching;

namespace ICSharpCode.Decompiler.Ast
{
Expand All @@ -29,6 +30,16 @@ public static T Detach<T>(this T node) where T : AstNode
return node;
}

public static Expression WithName(this Expression node, string patternGroupName)
{
return new NamedNode(patternGroupName, node);
}

public static Statement WithName(this Statement node, string patternGroupName)
{
return new NamedNode(patternGroupName, node);
}

public static void AddNamedArgument(this NRefactory.CSharp.Attribute attribute, string name, Expression argument)
{
attribute.Arguments.Add(new AssignmentExpression(new IdentifierExpression(name), argument));
Expand Down
Loading

0 comments on commit 858e6c0

Please sign in to comment.