override internal IntPtr Create(TypeBuilder builder) { RuntimeTypeHandle[] typeArgs = null; RuntimeTypeHandle[] methodArgs = null; if (!MethodArgs.IsNull) { methodArgs = builder.GetRuntimeTypeHandles(MethodArgs); } if (!TypeArgs.IsNull) { typeArgs = builder.GetRuntimeTypeHandles(TypeArgs); } CallConverterThunk.ThunkKind thunkKind; switch (Flags) { case NativeFormat.CallingConventionConverterKind.NoInstantiatingParam: thunkKind = CallConverterThunk.ThunkKind.GenericToStandardWithTargetPointerArg; break; case NativeFormat.CallingConventionConverterKind.HasInstantiatingParam: thunkKind = CallConverterThunk.ThunkKind.GenericToStandardWithTargetPointerArgAndParamArg; break; case NativeFormat.CallingConventionConverterKind.MaybeInstantiatingParam: thunkKind = CallConverterThunk.ThunkKind.GenericToStandardWithTargetPointerArgAndMaybeParamArg; break; default: throw new NotSupportedException(); } IntPtr result = CallConverterThunk.MakeThunk(thunkKind, IntPtr.Zero, Signature, IntPtr.Zero, typeArgs, methodArgs); return result; }
internal override unsafe IntPtr Create(TypeBuilder builder) { return TypeLoaderEnvironment.Instance.TryGetRuntimeMethodHandleForComponents( builder.GetRuntimeTypeHandle(Method.OwningType), MethodName, MethodSignature, builder.GetRuntimeTypeHandles(Method.Instantiation)); }
private IntPtr BuildCallingConventionConverter(TypeBuilder builder, IntPtr pointerToUse, IntPtr dictionary, bool usgConverter) { RuntimeTypeHandle[] typeArgs = Empty<RuntimeTypeHandle>.Array; RuntimeTypeHandle[] methodArgs = Empty<RuntimeTypeHandle>.Array; typeArgs = builder.GetRuntimeTypeHandles(_methodToUseForInstantiatingParameters.OwningType.Instantiation); bool containingTypeIsValueType = _methodToUseForInstantiatingParameters.OwningType.IsValueType; bool genericMethod = (_methodToUseForInstantiatingParameters.Instantiation.Length > 0); methodArgs = builder.GetRuntimeTypeHandles(_methodToUseForInstantiatingParameters.Instantiation); Debug.Assert(!MethodSignature.IsNativeLayoutSignature || (MethodSignature.NativeLayoutSignature != IntPtr.Zero)); CallConverterThunk.ThunkKind thunkKind; if (usgConverter) { if (genericMethod || containingTypeIsValueType) { if (dictionary == IntPtr.Zero) thunkKind = CallConverterThunk.ThunkKind.StandardToGenericPassthruInstantiating; else thunkKind = CallConverterThunk.ThunkKind.StandardToGenericInstantiating; } else { if (dictionary == IntPtr.Zero) thunkKind = CallConverterThunk.ThunkKind.StandardToGenericPassthruInstantiatingIfNotHasThis; else thunkKind = CallConverterThunk.ThunkKind.StandardToGenericInstantiatingIfNotHasThis; } } else { thunkKind = CallConverterThunk.ThunkKind.StandardToStandardInstantiating; } IntPtr thunkPtr = CallConverterThunk.MakeThunk( thunkKind, Method.UsgFunctionPointer, MethodSignature, dictionary, typeArgs, methodArgs); Debug.Assert(thunkPtr != IntPtr.Zero); return thunkPtr; }
override internal IntPtr Create(TypeBuilder builder) { RuntimeMethodHandle rmh; TypeLoaderEnvironment.Instance.TryGetRuntimeMethodHandleForComponents( builder.GetRuntimeTypeHandle(ConstrainedMethod.OwningType), MethodName, MethodSignature, builder.GetRuntimeTypeHandles(ConstrainedMethod.Instantiation), out rmh); return ConstrainedCallSupport.GenericConstrainedCallDesc.Get(builder.GetRuntimeTypeHandle(ConstraintType), rmh); }