Browse Source

Fixed some corner cases

pull/587/head
LordJZ 10 years ago
parent
commit
7cacb70148
  1. 3
      ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs
  2. 5
      ICSharpCode.Decompiler/Tests/UnsafeCode.cs

3
ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs

@ -839,7 +839,8 @@ namespace ICSharpCode.Decompiler.ILAst @@ -839,7 +839,8 @@ namespace ICSharpCode.Decompiler.ILAst
}
}
adjustmentExpr = new ILExpression(divide ? ILCode.Div_Un : ILCode.Mul, null, adjustmentExpr, sizeOfExpression);
if (!(sizeOfExpression.Code == ILCode.Ldc_I4 && (int)sizeOfExpression.Operand == 1))
adjustmentExpr = new ILExpression(divide ? ILCode.Div_Un : ILCode.Mul, null, adjustmentExpr, sizeOfExpression);
}
public static void ReplaceVariables(ILNode node, Func<ILVariable, ILVariable> variableMapping)

5
ICSharpCode.Decompiler/Tests/UnsafeCode.cs

@ -143,6 +143,11 @@ public class UnsafeCode @@ -143,6 +143,11 @@ public class UnsafeCode
return (long*)((byte*)p + 3);
}
public unsafe int PointerArithmetic5(void* p, byte* q, int i)
{
return (int)(q[i] + *(byte*)p);
}
public unsafe int PointerSubtraction(long* p, long* q)
{
return (int)((long)(p - q));

Loading…
Cancel
Save