Browse Source

Add support for char literals.

pull/37/head
Daniel Grunwald 15 years ago
parent
commit
e31a89689d
  1. 10
      ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs
  2. 4
      ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs
  3. 1
      ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs

10
ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs

@ -514,7 +514,7 @@ namespace Decompiler @@ -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 @@ -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 @@ -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 @@ -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);

4
ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs

@ -36,7 +36,7 @@ namespace Decompiler.ControlFlow @@ -36,7 +36,7 @@ namespace Decompiler.ControlFlow
foreach(ILBlock block in method.GetSelfAndChildrenRecursive<ILBlock>().ToList()) {
ControlFlowGraph graph;
graph = BuildGraph(block.Body, (ILLabel)block.EntryGoto.Operand);
graph.ComputeDominance();
graph.ComputeDominance(context.CancellationToken);
graph.ComputeDominanceFrontier();
block.Body = FindLoops(new HashSet<ControlFlowNode>(graph.Nodes.Skip(3)), graph.EntryPoint, false);
}
@ -49,7 +49,7 @@ namespace Decompiler.ControlFlow @@ -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<ControlFlowNode>(graph.Nodes.Skip(3)), graph.EntryPoint);
}

1
ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs

@ -646,6 +646,7 @@ namespace Decompiler @@ -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:

Loading…
Cancel
Save