|
|
|
@ -52,8 +52,8 @@ namespace ICSharpCode.Decompiler.Ast
@@ -52,8 +52,8 @@ namespace ICSharpCode.Decompiler.Ast
|
|
|
|
|
/// These are used to update the parameter names when the decompiler generates names for the parameters.</param>
|
|
|
|
|
/// <returns>Block for the method body</returns>
|
|
|
|
|
public static BlockStatement CreateMethodBody(MethodDefinition methodDef, |
|
|
|
|
DecompilerContext context, |
|
|
|
|
IEnumerable<ParameterDeclaration> parameters = null) |
|
|
|
|
DecompilerContext context, |
|
|
|
|
IEnumerable<ParameterDeclaration> parameters = null) |
|
|
|
|
{ |
|
|
|
|
MethodDefinition oldCurrentMethod = context.CurrentMethod; |
|
|
|
|
Debug.Assert(oldCurrentMethod == null || oldCurrentMethod == methodDef); |
|
|
|
@ -103,8 +103,8 @@ namespace ICSharpCode.Decompiler.Ast
@@ -103,8 +103,8 @@ namespace ICSharpCode.Decompiler.Ast
|
|
|
|
|
|
|
|
|
|
if (parameters != null) { |
|
|
|
|
foreach (var pair in (from p in parameters |
|
|
|
|
join v in astBuilder.Parameters on p.Annotation<ParameterDefinition>() equals v.OriginalParameter |
|
|
|
|
select new { p, v.Name })) |
|
|
|
|
join v in astBuilder.Parameters on p.Annotation<ParameterDefinition>() equals v.OriginalParameter |
|
|
|
|
select new { p, v.Name })) |
|
|
|
|
{ |
|
|
|
|
pair.p.Name = pair.Name; |
|
|
|
|
} |
|
|
|
@ -204,7 +204,7 @@ namespace ICSharpCode.Decompiler.Ast
@@ -204,7 +204,7 @@ namespace ICSharpCode.Decompiler.Ast
|
|
|
|
|
tryCatchStmt.TryBlock = TransformBlock(tryCatchNode.TryBlock); |
|
|
|
|
foreach (var catchClause in tryCatchNode.CatchBlocks) { |
|
|
|
|
if (catchClause.ExceptionVariable == null |
|
|
|
|
&& (catchClause.ExceptionType == null || catchClause.ExceptionType.MetadataType == MetadataType.Object)) |
|
|
|
|
&& (catchClause.ExceptionType == null || catchClause.ExceptionType.MetadataType == MetadataType.Object)) |
|
|
|
|
{ |
|
|
|
|
tryCatchStmt.CatchClauses.Add(new Ast.CatchClause { Body = TransformBlock(catchClause) }); |
|
|
|
|
} else { |
|
|
|
@ -460,12 +460,30 @@ namespace ICSharpCode.Decompiler.Ast
@@ -460,12 +460,30 @@ namespace ICSharpCode.Decompiler.Ast
|
|
|
|
|
// can also mean Inequality, when used with object references
|
|
|
|
|
TypeReference arg1Type = byteCode.Arguments[0].InferredType; |
|
|
|
|
if (arg1Type != null && !arg1Type.IsValueType) goto case ILCode.Cne; |
|
|
|
|
|
|
|
|
|
// when comparing signed integral values using Cgt_Un with 0
|
|
|
|
|
// the Ast should actually contain InEquality since "(uint)a > 0u" is identical to "a != 0"
|
|
|
|
|
if (arg1Type.IsSignedIntegralType()) |
|
|
|
|
{ |
|
|
|
|
var p = arg2 as Ast.PrimitiveExpression; |
|
|
|
|
if (p != null && p.Value.IsZero()) goto case ILCode.Cne; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
goto case ILCode.Cgt; |
|
|
|
|
} |
|
|
|
|
case ILCode.Cle_Un: { |
|
|
|
|
// can also mean Equality, when used with object references
|
|
|
|
|
TypeReference arg1Type = byteCode.Arguments[0].InferredType; |
|
|
|
|
if (arg1Type != null && !arg1Type.IsValueType) goto case ILCode.Ceq; |
|
|
|
|
|
|
|
|
|
// when comparing signed integral values using Cle_Un with 0
|
|
|
|
|
// the Ast should actually contain Equality since "(uint)a <= 0u" is identical to "a == 0"
|
|
|
|
|
if (arg1Type.IsSignedIntegralType()) |
|
|
|
|
{ |
|
|
|
|
var p = arg2 as Ast.PrimitiveExpression; |
|
|
|
|
if (p != null && p.Value.IsZero()) goto case ILCode.Ceq; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
goto case ILCode.Cle; |
|
|
|
|
} |
|
|
|
|
case ILCode.Cle: return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.LessThanOrEqual, arg2); |
|
|
|
|