|
|
|
@ -168,7 +168,7 @@ namespace ICSharpCode.Decompiler.CSharp
@@ -168,7 +168,7 @@ namespace ICSharpCode.Decompiler.CSharp
|
|
|
|
|
/// From the caller's perspective, IntPtr/UIntPtr behave like normal C# integers except that they have native int size.
|
|
|
|
|
/// All the special cases necessary to make IntPtr/UIntPtr behave sanely are handled internally in ConvertTo().
|
|
|
|
|
/// </remarks>
|
|
|
|
|
public TranslatedExpression ConvertTo(IType targetType, ExpressionBuilder expressionBuilder, bool checkForOverflow = false) |
|
|
|
|
public TranslatedExpression ConvertTo(IType targetType, ExpressionBuilder expressionBuilder, bool checkForOverflow = false, bool allowImplicitConversion = false) |
|
|
|
|
{ |
|
|
|
|
var type = this.Type; |
|
|
|
|
if (type.Equals(targetType)) |
|
|
|
@ -294,6 +294,10 @@ namespace ICSharpCode.Decompiler.CSharp
@@ -294,6 +294,10 @@ namespace ICSharpCode.Decompiler.CSharp
|
|
|
|
|
.WithILInstruction(this.ILInstructions) |
|
|
|
|
.WithRR(new ConstantResolveResult(targetType, null)); |
|
|
|
|
} |
|
|
|
|
var conversions = Resolver.CSharpConversions.Get(compilation); |
|
|
|
|
if (allowImplicitConversion && conversions.ImplicitConversion(type, targetType).IsValid) { |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
var castExpr = new CastExpression(expressionBuilder.ConvertType(targetType), Expression); |
|
|
|
|
castExpr.AddAnnotation(checkForOverflow ? AddCheckedBlocks.CheckedAnnotation : AddCheckedBlocks.UncheckedAnnotation); |
|
|
|
|
return castExpr.WithoutILInstruction().WithRR(rr); |
|
|
|
|