Permalink
Browse files

Add support for char literals.

  • Loading branch information...
1 parent e8f9feb commit e31a89689d143b16d7ac4471c5dd93781ac60893 @dgrunwald dgrunwald committed Feb 22, 2011
@@ -514,7 +514,7 @@ AstNode TransformByteCode(ILExpression byteCode, List<Ast.Expression> args)
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,16 +763,16 @@ Ast.Expression Convert(Ast.Expression expr, Cecil.TypeReference actualType, Ceci
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());
}
}
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 @@ Ast.Expression Convert(Ast.Expression expr, Cecil.TypeReference actualType, Ceci
}
}
- Expression PrimitiveExpression(long val, TypeReference type)
+ Expression MakePrimitive(long val, TypeReference type)
{
if (TypeAnalysis.IsBoolean(type) && val == 0)
return new Ast.PrimitiveExpression(false);
@@ -36,7 +36,7 @@ public void Optimize(DecompilerContext context, ILBlock method, ILAstOptimizatio
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 @@ public void Optimize(DecompilerContext context, ILBlock method, ILAstOptimizatio
// 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);
}
@@ -646,6 +646,7 @@ public static bool IsIntegerOrEnum(TypeReference type)
case MetadataType.IntPtr:
return true;
case MetadataType.Byte:
+ case MetadataType.Char:
case MetadataType.UInt16:
case MetadataType.UInt32:
case MetadataType.UInt64:

0 comments on commit e31a896

Please sign in to comment.