From e31a89689d143b16d7ac4471c5dd93781ac60893 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Tue, 22 Feb 2011 16:56:31 +0100 Subject: [PATCH] Add support for char literals. --- ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs | 10 +++++----- ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs | 4 ++-- ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs b/ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs index 663b59236..eabbc2203 100644 --- a/ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs +++ b/ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs @@ -514,7 +514,7 @@ namespace Decompiler return MakeRef(new Ast.IdentifierExpression(((ParameterDefinition)operand).Name).WithAnnotation(operand)); } case Code.Ldc_I4: - return PrimitiveExpression((int)operand, byteCode.InferredType); + return MakePrimitive((int)operand, byteCode.InferredType); case Code.Ldc_I8: case Code.Ldc_R4: case Code.Ldc_R8: @@ -763,7 +763,7 @@ namespace Decompiler if (TypeAnalysis.IsBoolean(actualType)) return expr; if (actualIsIntegerOrEnum) { - return new BinaryOperatorExpression(expr, BinaryOperatorType.InEquality, PrimitiveExpression(0, actualType)); + return new BinaryOperatorExpression(expr, BinaryOperatorType.InEquality, MakePrimitive(0, actualType)); } else { return new BinaryOperatorExpression(expr, BinaryOperatorType.InEquality, new NullReferenceExpression()); } @@ -771,8 +771,8 @@ namespace Decompiler if (TypeAnalysis.IsBoolean(actualType) && requiredIsIntegerOrEnum) { return new ConditionalExpression { Condition = expr, - TrueExpression = PrimitiveExpression(1, reqType), - FalseExpression = PrimitiveExpression(0, reqType) + TrueExpression = MakePrimitive(1, reqType), + FalseExpression = MakePrimitive(0, reqType) }; } if (actualIsIntegerOrEnum && requiredIsIntegerOrEnum) { @@ -782,7 +782,7 @@ namespace Decompiler } } - Expression PrimitiveExpression(long val, TypeReference type) + Expression MakePrimitive(long val, TypeReference type) { if (TypeAnalysis.IsBoolean(type) && val == 0) return new Ast.PrimitiveExpression(false); diff --git a/ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs b/ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs index 38825bf99..ece707daf 100644 --- a/ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs +++ b/ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs @@ -36,7 +36,7 @@ namespace Decompiler.ControlFlow foreach(ILBlock block in method.GetSelfAndChildrenRecursive().ToList()) { ControlFlowGraph graph; graph = BuildGraph(block.Body, (ILLabel)block.EntryGoto.Operand); - graph.ComputeDominance(); + graph.ComputeDominance(context.CancellationToken); graph.ComputeDominanceFrontier(); block.Body = FindLoops(new HashSet(graph.Nodes.Skip(3)), graph.EntryPoint, false); } @@ -49,7 +49,7 @@ namespace Decompiler.ControlFlow // TODO: Fix if (graph == null) continue; - graph.ComputeDominance(); + graph.ComputeDominance(context.CancellationToken); graph.ComputeDominanceFrontier(); block.Body = FindConditions(new HashSet(graph.Nodes.Skip(3)), graph.EntryPoint); } diff --git a/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs b/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs index 028d045c7..6c79b565e 100644 --- a/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs +++ b/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs @@ -646,6 +646,7 @@ namespace Decompiler case MetadataType.IntPtr: return true; case MetadataType.Byte: + case MetadataType.Char: case MetadataType.UInt16: case MetadataType.UInt32: case MetadataType.UInt64: