public IList <CilExpression> RecompileCallArguments( IMethodDescriptor method, IList <ILExpression> arguments, VMECallOpCode opCode, ITypeDescriptor constrainedType = null) { var methodSig = method.Signature; var result = new List <CilExpression>(); // Emit arguments. for (var i = 0; i < arguments.Count; i++) { // Recompile argument. var cilArgument = (CilExpression)arguments[i].AcceptVisitor(Recompiler); // Figure out expected argument type. TypeSignature argumentType; if (methodSig.HasThis && opCode != VMECallOpCode.NEWOBJ) { // Instance method invocation. if (i == 0) { // First parameter is the object instance that this method is called on (implicit this parameter). argumentType = constrainedType?.ToTypeSignature() ?? method.DeclaringType.ToTypeSignature(); // Calls on instance methods of value types need the this parameter to be passed on by-ref. if (argumentType.IsValueType) { argumentType = new ByReferenceTypeSignature(argumentType); } } else { argumentType = methodSig.ParameterTypes[i - 1]; } } else { // Static method invocation. argumentType = methodSig.ParameterTypes[i]; } cilArgument.ExpectedType = argumentType.InstantiateGenericTypes(GenericContext); result.Add(cilArgument); } return(result); }
public ECallAnnotation(IMethodDescriptor method, VMECallOpCode opCode) : base(VMCalls.ECALL, method.Signature.ReturnType.ToVMType()) { Method = method; OpCode = opCode; }
public ECallAnnotation(ICallableMemberReference method, VMECallOpCode opCode) : base(VMCalls.ECALL, ((MethodSignature)method.Signature).ReturnType.ToVMType()) { Method = method; OpCode = opCode; }