Пример #1
0
        public static ILGenerator ReturnFromMethodOnObject(this ILGenerator generator, MethodInfo method)
        {
            if (typeof(void) == method.ReturnType)
            {
                generator.AndEmit(OpCodes.Ldnull);
            }
            else if (method.ReturnType.IsValueType)
            {
                generator.AndEmit(OpCodes.Box, method.ReturnType);
            }

            return(generator.AndReturnObject());
        }
Пример #2
0
 public static ILGenerator AndPushElementFromArrayAtIndexOnStackOntoStack(this ILGenerator generator)
 {
     return(generator.AndEmit(OpCodes.Ldelem_Ref));
 }
Пример #3
0
 public static ILGenerator AndReturnObject(this ILGenerator generator)
 {
     return(generator.AndEmit(OpCodes.Ret));
 }
Пример #4
0
 public static ILGenerator AndGotoLabelIfTop2ItemsOnStackAreEqual(this ILGenerator generator, Label arg)
 {
     return(generator.AndEmit(OpCodes.Beq, arg));
 }
Пример #5
0
 public static ILGenerator AndThrowExceptionFromStack(this ILGenerator generator)
 {
     return(generator.AndEmit(OpCodes.Throw));
 }
Пример #6
0
 public static ILGenerator AndPushNewObjectOntoStack(this ILGenerator generator, ConstructorInfo arg)
 {
     return(generator.AndEmit(OpCodes.Newobj, arg));
 }
Пример #7
0
 public static ILGenerator AndPushInt32AsInt32OntoStack(this ILGenerator generator, int arg)
 {
     return(generator.AndEmit(OpCodes.Ldc_I4, arg));
 }
Пример #8
0
 public static ILGenerator AndPushArrayLengthOntoStack(this ILGenerator generator)
 {
     return(generator.AndEmit(OpCodes.Ldlen));
 }
Пример #9
0
 public static ILGenerator AndPushArgumentSOntoStack(this ILGenerator generator)
 {
     return(generator.AndEmit(OpCodes.Ldarg_S));
 }
Пример #10
0
 public static ILGenerator AndInvokeMethodOnObject(this ILGenerator generator, MethodInfo method)
 {
     return(generator.AndEmit(method.IsFinal ? OpCodes.Call : OpCodes.Callvirt, method));
 }
Пример #11
0
 public static ILGenerator AndUnboxArgument(this ILGenerator generator, Type parameterType)
 {
     return(generator.AndEmit(OpCodes.Unbox_Any, parameterType));
 }