|
|
@ -40,6 +40,8 @@ namespace ICSharpCode.Decompiler.Ast.Transforms |
|
|
|
TransformAutomaticProperties(compilationUnit); |
|
|
|
TransformAutomaticProperties(compilationUnit); |
|
|
|
if (context.Settings.AutomaticEvents) |
|
|
|
if (context.Settings.AutomaticEvents) |
|
|
|
TransformAutomaticEvents(compilationUnit); |
|
|
|
TransformAutomaticEvents(compilationUnit); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TransformTryCatchFinally(compilationUnit); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -652,6 +654,33 @@ namespace ICSharpCode.Decompiler.Ast.Transforms |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Try-Catch-Finally
|
|
|
|
|
|
|
|
static readonly TryCatchStatement tryCatchFinallyPattern = new TryCatchStatement { |
|
|
|
|
|
|
|
TryBlock = new BlockStatement { |
|
|
|
|
|
|
|
new TryCatchStatement { |
|
|
|
|
|
|
|
TryBlock = new AnyNode(), |
|
|
|
|
|
|
|
CatchClauses = { new Repeat(new AnyNode()) } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
FinallyBlock = new AnyNode() |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// Simplify nested 'try { try {} catch {} } finally {}'.
|
|
|
|
|
|
|
|
/// This transformation must run after the using/lock tranformations.
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
void TransformTryCatchFinally(AstNode compilationUnit) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
foreach (var tryFinally in compilationUnit.Descendants.OfType<TryCatchStatement>()) { |
|
|
|
|
|
|
|
if (tryCatchFinallyPattern.Match(tryFinally) != null) { |
|
|
|
|
|
|
|
TryCatchStatement tryCatch = (TryCatchStatement)tryFinally.TryBlock.Statements.Single(); |
|
|
|
|
|
|
|
tryFinally.TryBlock = tryCatch.TryBlock.Detach(); |
|
|
|
|
|
|
|
tryCatch.CatchClauses.MoveTo(tryFinally.CatchClauses); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Pattern Matching Helpers
|
|
|
|
#region Pattern Matching Helpers
|
|
|
|
sealed class TypePattern : Pattern |
|
|
|
sealed class TypePattern : Pattern |
|
|
|
{ |
|
|
|
{ |
|
|
|