Browse Source

do not generate unused exception variables, transform unused object-typed exception variables to catch-all

pull/728/head
Siegfried Pammer 9 years ago
parent
commit
ebb9fdd79d
  1. 11
      ICSharpCode.Decompiler/CSharp/StatementBuilder.cs

11
ICSharpCode.Decompiler/CSharp/StatementBuilder.cs

@ -163,9 +163,14 @@ namespace ICSharpCode.Decompiler.CSharp
tryCatch.TryBlock = ConvertAsBlock(inst.TryBlock); tryCatch.TryBlock = ConvertAsBlock(inst.TryBlock);
foreach (var handler in inst.Handlers) { foreach (var handler in inst.Handlers) {
var catchClause = new CatchClause(); var catchClause = new CatchClause();
if (handler.Variable != null) { var v = handler.Variable;
catchClause.Type = exprBuilder.ConvertType(handler.Variable.Type); if (v != null) {
catchClause.VariableName = handler.Variable.Name; if (v.StoreCount > 1 || v.LoadCount > 0 || v.AddressCount > 0) {
catchClause.VariableName = v.Name;
catchClause.Type = exprBuilder.ConvertType(v.Type);
} else if (!v.Type.IsKnownType(KnownTypeCode.Object)) {
catchClause.Type = exprBuilder.ConvertType(v.Type);
}
} }
if (!handler.Filter.MatchLdcI4(1)) if (!handler.Filter.MatchLdcI4(1))
catchClause.Condition = exprBuilder.TranslateCondition(handler.Filter); catchClause.Condition = exprBuilder.TranslateCondition(handler.Filter);

Loading…
Cancel
Save