Browse Source

Hack - convert int to bool on == operator

pull/1/head^2
David Srbecký 18 years ago
parent
commit
ffef73b007
  1. 7
      src/AstMetodBodyBuilder.cs

7
src/AstMetodBodyBuilder.cs

@ -195,7 +195,7 @@ namespace Decompiler @@ -195,7 +195,7 @@ namespace Decompiler
case Code.Bne_Un: return new Ast.IfElseStatement(new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.InEquality, arg2), new Ast.GotoStatement(operandAsInstructionLabel));
#endregion
#region Comparison
case Code.Ceq: return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Equality, arg2);
case Code.Ceq: return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Equality, ConvertIntToBool(arg2));
case Code.Cgt: return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.GreaterThan, arg2);
case Code.Cgt_Un: return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.GreaterThan, arg2);
case Code.Clt: return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.LessThan, arg2);
@ -335,6 +335,11 @@ namespace Decompiler @@ -335,6 +335,11 @@ namespace Decompiler
}
}
static Ast.Expression ConvertIntToBool(Ast.Expression astInt)
{
return new Ast.ParenthesizedExpression(new Ast.BinaryOperatorExpression(astInt, BinaryOperatorType.InEquality, new Ast.PrimitiveExpression(0, "0")));
}
static object GetType(MethodDefinition methodDef, Instruction inst, params Cecil.TypeReference[] args)
{
OpCode opCode = inst.OpCode;

Loading…
Cancel
Save