Browse Source

Removed incorrect type inference for Add/Sub/Localloc

CIL can Add/Sub type * and type I, but C# can add 8 types to a pointer, but not IntPtr.
CIL can Localloc only type U, but C# only int.
pull/539/head
LordJZ 11 years ago
parent
commit
8b84fc6bb9
  1. 8
      ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs

8
ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs

@ -450,7 +450,7 @@ namespace ICSharpCode.Decompiler.ILAst
return (TypeReference)expr.Operand; return (TypeReference)expr.Operand;
case ILCode.Localloc: case ILCode.Localloc:
if (forceInferChildren) { if (forceInferChildren) {
InferTypeForExpression(expr.Arguments[0], typeSystem.Int32); InferTypeForExpression(expr.Arguments[0], null);
} }
if (expectedType is PointerType) if (expectedType is PointerType)
return expectedType; return expectedType;
@ -1013,7 +1013,7 @@ namespace ICSharpCode.Decompiler.ILAst
TypeReference leftPreferred = DoInferTypeForExpression(left, expectedType); TypeReference leftPreferred = DoInferTypeForExpression(left, expectedType);
if (leftPreferred is PointerType) { if (leftPreferred is PointerType) {
left.InferredType = left.ExpectedType = leftPreferred; left.InferredType = left.ExpectedType = leftPreferred;
InferTypeForExpression(right, typeSystem.IntPtr); InferTypeForExpression(right, null);
return leftPreferred; return leftPreferred;
} }
if (IsEnum(leftPreferred)) { if (IsEnum(leftPreferred)) {
@ -1024,7 +1024,7 @@ namespace ICSharpCode.Decompiler.ILAst
} }
TypeReference rightPreferred = DoInferTypeForExpression(right, expectedType); TypeReference rightPreferred = DoInferTypeForExpression(right, expectedType);
if (rightPreferred is PointerType) { if (rightPreferred is PointerType) {
InferTypeForExpression(left, typeSystem.IntPtr); InferTypeForExpression(left, null);
right.InferredType = right.ExpectedType = rightPreferred; right.InferredType = right.ExpectedType = rightPreferred;
return rightPreferred; return rightPreferred;
} }
@ -1044,7 +1044,7 @@ namespace ICSharpCode.Decompiler.ILAst
TypeReference leftPreferred = DoInferTypeForExpression(left, expectedType); TypeReference leftPreferred = DoInferTypeForExpression(left, expectedType);
if (leftPreferred is PointerType) { if (leftPreferred is PointerType) {
left.InferredType = left.ExpectedType = leftPreferred; left.InferredType = left.ExpectedType = leftPreferred;
InferTypeForExpression(right, typeSystem.IntPtr); InferTypeForExpression(right, null);
return leftPreferred; return leftPreferred;
} }
if (IsEnum(leftPreferred)) { if (IsEnum(leftPreferred)) {

Loading…
Cancel
Save