|
|
@ -98,8 +98,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!context.Settings.ExpressionTrees) return; |
|
|
|
if (!context.Settings.ExpressionTrees) return; |
|
|
|
this.context = context; |
|
|
|
this.context = context; |
|
|
|
this.conversions = CSharpConversions.Get(context.TypeSystem.Compilation); |
|
|
|
this.conversions = CSharpConversions.Get(context.TypeSystem); |
|
|
|
this.resolver = new CSharpResolver(context.TypeSystem.Compilation); |
|
|
|
this.resolver = new CSharpResolver(context.TypeSystem); |
|
|
|
this.parameters = new Dictionary<ILVariable, (IType, string)>(); |
|
|
|
this.parameters = new Dictionary<ILVariable, (IType, string)>(); |
|
|
|
this.parameterMapping = new Dictionary<ILVariable, ILVariable>(); |
|
|
|
this.parameterMapping = new Dictionary<ILVariable, ILVariable>(); |
|
|
|
this.instructionsToRemove = new List<ILInstruction>(); |
|
|
|
this.instructionsToRemove = new List<ILInstruction>(); |
|
|
@ -377,7 +377,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
var (converted, arrayType) = ConvertInstruction(invocation.Arguments[0]); |
|
|
|
var (converted, arrayType) = ConvertInstruction(invocation.Arguments[0]); |
|
|
|
if (converted == null) |
|
|
|
if (converted == null) |
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
return (new LdLen(StackType.I4, converted), context.TypeSystem.Compilation.FindType(KnownTypeCode.Int32)); |
|
|
|
return (new LdLen(StackType.I4, converted), context.TypeSystem.FindType(KnownTypeCode.Int32)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
(ILInstruction, IType) ConvertBinaryNumericOperator(CallInstruction invocation, BinaryNumericOperator op, bool? isChecked = null) |
|
|
|
(ILInstruction, IType) ConvertBinaryNumericOperator(CallInstruction invocation, BinaryNumericOperator op, bool? isChecked = null) |
|
|
@ -589,7 +589,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
} |
|
|
|
} |
|
|
|
return (new Call(operatorMethod) { Arguments = { left, right } }, operatorMethod.ReturnType); |
|
|
|
return (new Call(operatorMethod) { Arguments = { left, right } }, operatorMethod.ReturnType); |
|
|
|
} |
|
|
|
} |
|
|
|
var resultType = context.TypeSystem.Compilation.FindType(KnownTypeCode.Boolean); |
|
|
|
var resultType = context.TypeSystem.FindType(KnownTypeCode.Boolean); |
|
|
|
return (new Comp(kind, NullableType.IsNullable(leftType) ? ComparisonLiftingKind.CSharp : ComparisonLiftingKind.None, leftType.GetStackType(), leftType.GetSign(), left, right), resultType); |
|
|
|
return (new Comp(kind, NullableType.IsNullable(leftType) ? ComparisonLiftingKind.CSharp : ComparisonLiftingKind.None, leftType.GetStackType(), leftType.GetSign(), left, right), resultType); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -739,7 +739,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
IMember method; |
|
|
|
IMember method; |
|
|
|
switch (invocation.Arguments.Count) { |
|
|
|
switch (invocation.Arguments.Count) { |
|
|
|
case 2: |
|
|
|
case 2: |
|
|
|
var resultType = context.TypeSystem.Compilation.FindType(KnownTypeCode.Boolean); |
|
|
|
var resultType = context.TypeSystem.FindType(KnownTypeCode.Boolean); |
|
|
|
return (and ? IfInstruction.LogicAnd(left, right) : IfInstruction.LogicOr(left, right), resultType); |
|
|
|
return (and ? IfInstruction.LogicAnd(left, right) : IfInstruction.LogicOr(left, right), resultType); |
|
|
|
case 3: |
|
|
|
case 3: |
|
|
|
if (!MatchGetMethodFromHandle(invocation.Arguments[2], out method)) |
|
|
|
if (!MatchGetMethodFromHandle(invocation.Arguments[2], out method)) |
|
|
@ -810,7 +810,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
indices[i] = index; |
|
|
|
indices[i] = index; |
|
|
|
} |
|
|
|
} |
|
|
|
return (new NewArr(type, indices), new ArrayType(context.TypeSystem.Compilation, type, arguments.Count)); |
|
|
|
return (new NewArr(type, indices), new ArrayType(context.TypeSystem, type, arguments.Count)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
(ILInstruction, IType) ConvertNewArrayInit(CallInstruction invocation) |
|
|
|
(ILInstruction, IType) ConvertNewArrayInit(CallInstruction invocation) |
|
|
@ -821,7 +821,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
if (!MatchArgumentList(invocation.Arguments[1], out var arguments)) |
|
|
|
if (!MatchArgumentList(invocation.Arguments[1], out var arguments)) |
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
ArrayType arrayType = new ArrayType(context.BlockContext.TypeSystem.Compilation, type); |
|
|
|
ArrayType arrayType = new ArrayType(context.BlockContext.TypeSystem, type); |
|
|
|
if (arguments.Count == 0) |
|
|
|
if (arguments.Count == 0) |
|
|
|
return (new NewArr(type, new LdcI4(0)), arrayType); |
|
|
|
return (new NewArr(type, new LdcI4(0)), arrayType); |
|
|
|
var block = (Block)invocation.Arguments[1]; |
|
|
|
var block = (Block)invocation.Arguments[1]; |
|
|
@ -959,7 +959,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
var converted = ConvertInstruction(invocation.Arguments[0]).Item1; |
|
|
|
var converted = ConvertInstruction(invocation.Arguments[0]).Item1; |
|
|
|
if (!MatchGetTypeFromHandle(invocation.Arguments[1], out var type)) |
|
|
|
if (!MatchGetTypeFromHandle(invocation.Arguments[1], out var type)) |
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
var resultType = context.TypeSystem.Compilation.FindType(KnownTypeCode.Boolean); |
|
|
|
var resultType = context.TypeSystem.FindType(KnownTypeCode.Boolean); |
|
|
|
if (converted != null) |
|
|
|
if (converted != null) |
|
|
|
return (new Comp(ComparisonKind.Inequality, Sign.None, new IsInst(converted, type), new LdNull()), resultType); |
|
|
|
return (new Comp(ComparisonKind.Inequality, Sign.None, new IsInst(converted, type), new LdNull()), resultType); |
|
|
|
return (null, SpecialType.UnknownType); |
|
|
|
return (null, SpecialType.UnknownType); |
|
|
@ -1061,7 +1061,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
//castclass System.Reflection.MethodInfo(call GetMethodFromHandle(ldmembertoken op_Addition))
|
|
|
|
//castclass System.Reflection.MethodInfo(call GetMethodFromHandle(ldmembertoken op_Addition))
|
|
|
|
if (!inst.MatchCastClass(out var arg, out var type)) |
|
|
|
if (!inst.MatchCastClass(out var arg, out var type)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
if (!type.Equals(context.TypeSystem.Compilation.FindType(new FullTypeName("System.Reflection.MethodInfo")))) |
|
|
|
if (!type.Equals(context.TypeSystem.FindType(new FullTypeName("System.Reflection.MethodInfo")))) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
if (!(arg is CallInstruction call && call.Method.FullName == "System.Reflection.MethodBase.GetMethodFromHandle")) |
|
|
|
if (!(arg is CallInstruction call && call.Method.FullName == "System.Reflection.MethodBase.GetMethodFromHandle")) |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -1086,7 +1086,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
//castclass System.Reflection.ConstructorInfo(call GetMethodFromHandle(ldmembertoken op_Addition))
|
|
|
|
//castclass System.Reflection.ConstructorInfo(call GetMethodFromHandle(ldmembertoken op_Addition))
|
|
|
|
if (!inst.MatchCastClass(out var arg, out var type)) |
|
|
|
if (!inst.MatchCastClass(out var arg, out var type)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
if (!type.Equals(context.TypeSystem.Compilation.FindType(new FullTypeName("System.Reflection.ConstructorInfo")))) |
|
|
|
if (!type.Equals(context.TypeSystem.FindType(new FullTypeName("System.Reflection.ConstructorInfo")))) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
if (!(arg is CallInstruction call && call.Method.FullName == "System.Reflection.MethodBase.GetMethodFromHandle")) |
|
|
|
if (!(arg is CallInstruction call && call.Method.FullName == "System.Reflection.MethodBase.GetMethodFromHandle")) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|