|
|
|
@ -153,7 +153,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -153,7 +153,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
/// Converts a Expression.Lambda call into an ILFunction.
|
|
|
|
|
/// If the conversion fails, null is returned.
|
|
|
|
|
/// </summary>
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertLambda(CallInstruction instruction) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertLambda(CallInstruction instruction) |
|
|
|
|
{ |
|
|
|
|
if (instruction.Method.Name != "Lambda" || instruction.Arguments.Count != 2 || instruction.Method.ReturnType.FullName != "System.Linq.Expressions.Expression" || instruction.Method.ReturnType.TypeArguments.Count != 1) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -198,7 +198,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -198,7 +198,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertQuote(CallInstruction invocation) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertQuote(CallInstruction invocation) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count != 1) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -266,7 +266,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -266,7 +266,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertInstruction(ILInstruction instruction, IType? typeHint = null) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertInstruction(ILInstruction instruction, IType? typeHint = null) |
|
|
|
|
{ |
|
|
|
|
var (inst, type) = Convert(); |
|
|
|
|
|
|
|
|
@ -289,7 +289,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -289,7 +289,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
} |
|
|
|
|
return (DoConvert, typeHint ?? type); |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) Convert() |
|
|
|
|
(Func<ILInstruction>?, IType) Convert() |
|
|
|
|
{ |
|
|
|
|
switch (instruction) |
|
|
|
|
{ |
|
|
|
@ -446,7 +446,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -446,7 +446,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
return delegateType; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertArrayIndex(CallInstruction invocation) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertArrayIndex(CallInstruction invocation) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count != 2) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -473,7 +473,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -473,7 +473,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
return (Convert, type.ElementType); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertArrayLength(CallInstruction invocation) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertArrayLength(CallInstruction invocation) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count != 1) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -483,7 +483,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -483,7 +483,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
return (() => new LdLen(StackType.I4, converted()), context.TypeSystem.FindType(KnownTypeCode.Int32)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertBinaryNumericOperator(CallInstruction invocation, BinaryNumericOperator op, bool? isChecked = null) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertBinaryNumericOperator(CallInstruction invocation, BinaryNumericOperator op, bool? isChecked = null) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count < 2) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -574,7 +574,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -574,7 +574,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertCall(CallInstruction invocation) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertCall(CallInstruction invocation) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count < 2) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -697,7 +697,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -697,7 +697,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
return converted; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertCast(CallInstruction invocation, bool isChecked) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertCast(CallInstruction invocation, bool isChecked) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count < 2) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -711,7 +711,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -711,7 +711,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
return (() => new ExpressionTreeCast(targetType, expr(), isChecked), targetType); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertCoalesce(CallInstruction invocation) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertCoalesce(CallInstruction invocation) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count != 2) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -742,7 +742,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -742,7 +742,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
}, targetType); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertComparison(CallInstruction invocation, ComparisonKind kind) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertComparison(CallInstruction invocation, ComparisonKind kind) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count < 2) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -790,7 +790,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -790,7 +790,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
return (() => new Comp(kind, lifting, utype.GetStackType(), utype.GetSign(), left(), right()), resultType); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertCondition(CallInstruction invocation) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertCondition(CallInstruction invocation) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count != 3) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -808,7 +808,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -808,7 +808,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
return (() => new IfInstruction(condition(), trueInst(), falseInst()), trueInstType); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertConstant(CallInstruction invocation) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertConstant(CallInstruction invocation) |
|
|
|
|
{ |
|
|
|
|
if (!MatchConstantCall(invocation, out var value, out var type)) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -821,7 +821,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -821,7 +821,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
return (() => ConvertValue(value, invocation), type); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertElementInit(CallInstruction invocation) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertElementInit(CallInstruction invocation) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count != 2) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -849,7 +849,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -849,7 +849,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
return (BuildCall, member.ReturnType); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertField(CallInstruction invocation, IType typeHint) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertField(CallInstruction invocation, IType typeHint) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count != 2) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -896,7 +896,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -896,7 +896,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertInvoke(CallInstruction invocation) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertInvoke(CallInstruction invocation) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count != 2) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -922,7 +922,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -922,7 +922,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
return (BuildCall, invokeMethod.ReturnType); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertListInit(CallInstruction invocation) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertListInit(CallInstruction invocation) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count < 2) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -978,7 +978,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -978,7 +978,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
return (BuildBlock, ctor.DeclaringType); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertLogicOperator(CallInstruction invocation, bool and) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertLogicOperator(CallInstruction invocation, bool and) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count < 2) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -1016,7 +1016,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -1016,7 +1016,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertMemberInit(CallInstruction invocation) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertMemberInit(CallInstruction invocation) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count != 2) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -1064,7 +1064,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -1064,7 +1064,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
return (BuildBlock, ctor.DeclaringType); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertNewArrayBounds(CallInstruction invocation) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertNewArrayBounds(CallInstruction invocation) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count != 2) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -1085,7 +1085,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -1085,7 +1085,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
return (() => new NewArr(type, indices.SelectArray(f => f())), new ArrayType(context.TypeSystem, type, arguments.Count)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertNewArrayInit(CallInstruction invocation) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertNewArrayInit(CallInstruction invocation) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count != 2) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -1154,7 +1154,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -1154,7 +1154,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertNewObject(CallInstruction invocation) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertNewObject(CallInstruction invocation) |
|
|
|
|
{ |
|
|
|
|
switch (invocation.Arguments.Count) |
|
|
|
|
{ |
|
|
|
@ -1203,7 +1203,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -1203,7 +1203,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertNotOperator(CallInstruction invocation) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertNotOperator(CallInstruction invocation) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count < 1) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -1229,7 +1229,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -1229,7 +1229,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertProperty(CallInstruction invocation) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertProperty(CallInstruction invocation) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count < 2) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -1272,7 +1272,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -1272,7 +1272,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
return (BuildProperty, member.ReturnType); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertTypeAs(CallInstruction invocation) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertTypeAs(CallInstruction invocation) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count != 2) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -1293,7 +1293,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -1293,7 +1293,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
return (BuildTypeAs, type); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertTypeIs(CallInstruction invocation) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertTypeIs(CallInstruction invocation) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count != 2) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
@ -1306,7 +1306,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -1306,7 +1306,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(Func<ILInstruction>, IType) ConvertUnaryNumericOperator(CallInstruction invocation, BinaryNumericOperator op, bool? isChecked = null) |
|
|
|
|
(Func<ILInstruction>?, IType) ConvertUnaryNumericOperator(CallInstruction invocation, BinaryNumericOperator op, bool? isChecked = null) |
|
|
|
|
{ |
|
|
|
|
if (invocation.Arguments.Count < 1) |
|
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
|