本文整理汇总了C#中IKVM.Internal.MethodWrapper.GetDefineMethodHelper方法的典型用法代码示例。如果您正苦于以下问题:C# MethodWrapper.GetDefineMethodHelper方法的具体用法?C# MethodWrapper.GetDefineMethodHelper怎么用?C# MethodWrapper.GetDefineMethodHelper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IKVM.Internal.MethodWrapper
的用法示例。
在下文中一共展示了MethodWrapper.GetDefineMethodHelper方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitDispatch
private static void EmitDispatch(DynamicTypeWrapper.FinishContext context, TypeWrapper[] args, TypeBuilder tb, MethodWrapper interfaceMethod, TypeWrapper[] implParameters,
ClassFile.ConstantPoolItemMethodHandle implMethod, ClassFile.ConstantPoolItemMethodType instantiatedMethodType, FieldBuilder[] capturedFields)
{
MethodBuilder mb = interfaceMethod.GetDefineMethodHelper().DefineMethod(context.TypeWrapper, tb, interfaceMethod.Name, MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.NewSlot | MethodAttributes.Final);
if (interfaceMethod.Name != interfaceMethod.RealName)
{
tb.DefineMethodOverride(mb, (MethodInfo)interfaceMethod.GetMethod());
}
CodeEmitter ilgen = CodeEmitter.Create(mb);
for (int i = 0; i < capturedFields.Length; i++)
{
ilgen.EmitLdarg(0);
OpCode opc = OpCodes.Ldfld;
if (i == 0 && args[0].IsGhost)
{
switch (implMethod.Kind)
{
case ClassFile.RefKind.invokeInterface:
case ClassFile.RefKind.invokeVirtual:
case ClassFile.RefKind.invokeSpecial:
opc = OpCodes.Ldflda;
break;
}
}
ilgen.Emit(opc, capturedFields[i]);
}
for (int i = 0, count = interfaceMethod.GetParameters().Length, k = capturedFields.Length; i < count; i++)
{
ilgen.EmitLdarg(i + 1);
TypeWrapper Ui = interfaceMethod.GetParameters()[i];
TypeWrapper Ti = instantiatedMethodType.GetArgTypes()[i];
TypeWrapper Aj = implParameters[i + k];
if (Ui == PrimitiveTypeWrapper.BYTE)
{
ilgen.Emit(OpCodes.Conv_I1);
}
if (Ti != Ui)
{
if (Ti.IsGhost)
{
Ti.EmitConvStackTypeToSignatureType(ilgen, Ui);
}
else if (Ui.IsGhost)
{
Ui.EmitConvSignatureTypeToStackType(ilgen);
}
else
{
Ti.EmitCheckcast(ilgen);
}
}
if (Ti != Aj)
{
if (Ti.IsPrimitive && !Aj.IsPrimitive)
{
Boxer.EmitBox(ilgen, Ti);
}
else if (!Ti.IsPrimitive && Aj.IsPrimitive)
{
TypeWrapper primitive = GetPrimitiveFromWrapper(Ti);
Boxer.EmitUnbox(ilgen, primitive, false);
if (primitive == PrimitiveTypeWrapper.BYTE)
{
ilgen.Emit(OpCodes.Conv_I1);
}
}
else if (Aj == PrimitiveTypeWrapper.LONG)
{
ilgen.Emit(OpCodes.Conv_I8);
}
else if (Aj == PrimitiveTypeWrapper.FLOAT)
{
ilgen.Emit(OpCodes.Conv_R4);
}
else if (Aj == PrimitiveTypeWrapper.DOUBLE)
{
ilgen.Emit(OpCodes.Conv_R8);
}
}
}
switch (implMethod.Kind)
{
case ClassFile.RefKind.invokeVirtual:
case ClassFile.RefKind.invokeInterface:
((MethodWrapper)implMethod.Member).EmitCallvirt(ilgen);
break;
case ClassFile.RefKind.newInvokeSpecial:
((MethodWrapper)implMethod.Member).EmitNewobj(ilgen);
break;
case ClassFile.RefKind.invokeStatic:
case ClassFile.RefKind.invokeSpecial:
((MethodWrapper)implMethod.Member).EmitCall(ilgen);
break;
default:
throw new InvalidOperationException();
}
TypeWrapper Ru = interfaceMethod.ReturnType;
TypeWrapper Ra = GetImplReturnType(implMethod);
TypeWrapper Rt = instantiatedMethodType.GetRetType();
if (Ra == PrimitiveTypeWrapper.BYTE)
//.........这里部分代码省略.........
示例2: DefineGhostMethod
protected override MethodBuilder DefineGhostMethod(string name, MethodAttributes attribs, MethodWrapper mw)
{
if(typeBuilderGhostInterface != null)
{
return mw.GetDefineMethodHelper().DefineMethod(this, typeBuilderGhostInterface, name, attribs);
}
return null;
}
示例3: DefineGhostMethod
protected override MethodBuilder DefineGhostMethod(TypeBuilder typeBuilder, string name, MethodAttributes attribs, MethodWrapper mw)
{
if(typeBuilderGhostInterface != null && mw.IsVirtual)
{
DefineMethodHelper helper = mw.GetDefineMethodHelper();
MethodBuilder stub = helper.DefineMethod(this, typeBuilder, name, MethodAttributes.Public);
((GhostMethodWrapper)mw).SetGhostMethod(stub);
return helper.DefineMethod(this, typeBuilderGhostInterface, name, attribs);
}
return null;
}