Esempio n. 1
0
        public static FluentIlGenerator Ldarg_Auto(this FluentIlGenerator fluentIlGenerator, short index)
        {
            switch (index)
            {
            case 0:
                fluentIlGenerator.Ldarg_0();
                break;

            case 1:
                fluentIlGenerator.Ldarg_1();
                break;

            case 2:
                fluentIlGenerator.Ldarg_2();
                break;

            case 3:
                fluentIlGenerator.Ldarg_3();
                break;

            default:
                if ((index > 0) && (index <= byte.MaxValue))
                {
                    fluentIlGenerator.Ldarg_S((byte)index);
                }
                else
                {
                    fluentIlGenerator.Ldarg(index);
                }
                break;
            }
            return(fluentIlGenerator);
        }
Esempio n. 2
0
 public static FluentIlGenerator BoxIfNeeded(this FluentIlGenerator fluentIlGenerator, Type type)
 {
     if (type.IsValueType)
     {
         fluentIlGenerator.Box(type);
     }
     return(fluentIlGenerator);
 }
Esempio n. 3
0
        public static FluentIlGenerator Ldc_I4_Auto(this FluentIlGenerator fluentIlGenerator, int value)
        {
            switch (value)
            {
            case -1:
                fluentIlGenerator.Ldc_I4_M1();
                break;

            case 0:
                fluentIlGenerator.Ldc_I4_0();
                break;

            case 1:
                fluentIlGenerator.Ldc_I4_1();
                break;

            case 2:
                fluentIlGenerator.Ldc_I4_2();
                break;

            case 3:
                fluentIlGenerator.Ldc_I4_3();
                break;

            case 4:
                fluentIlGenerator.Ldc_I4_4();
                break;

            case 5:
                fluentIlGenerator.Ldc_I4_5();
                break;

            case 6:
                fluentIlGenerator.Ldc_I4_6();
                break;

            case 7:
                fluentIlGenerator.Ldc_I4_7();
                break;

            case 8:
                fluentIlGenerator.Ldc_I4_8();
                break;

            default:
                if ((value > -129) && (value < 128))
                {
                    fluentIlGenerator.Ldc_I4_S((sbyte)value);
                }
                else
                {
                    fluentIlGenerator.Ldc_I4(value);
                }
                break;
            }
            return(fluentIlGenerator);
        }
Esempio n. 4
0
 public static FluentIlGenerator BoxOrCast(this FluentIlGenerator fluentIlGenerator, Type type)
 {
     if (type.IsValueType)
     {
         fluentIlGenerator.Box(type);
     }
     else
     {
         fluentIlGenerator.Castclass(type);
     }
     return(fluentIlGenerator);
 }
Esempio n. 5
0
 public static FluentIlGenerator CallOrVirt(this FluentIlGenerator fluentIlGenerator, MethodInfo methodInfo)
 {
     if (methodInfo.IsVirtual)
     {
         fluentIlGenerator.Callvirt(methodInfo);
     }
     else
     {
         fluentIlGenerator.Call(methodInfo);
     }
     return(fluentIlGenerator);
 }
Esempio n. 6
0
 public static FluentIlGenerator Ldloca_Auto(this FluentIlGenerator fluentIlGenerator, short index)
 {
     if ((index > 0) && (index <= byte.MaxValue))
     {
         fluentIlGenerator.Ldloca_S((byte)index);
     }
     else
     {
         fluentIlGenerator.Ldloca(index);
     }
     return(fluentIlGenerator);
 }
Esempio n. 7
0
 public static FluentIlGenerator CallOrVirt(this FluentIlGenerator fluentIlGenerator, MethodInfo methodInfo,
                                            Type[] optionalParameterTypes)
 {
     if (methodInfo.IsVirtual)
     {
         fluentIlGenerator.Callvirt(methodInfo, optionalParameterTypes);
     }
     else
     {
         fluentIlGenerator.Call(methodInfo, optionalParameterTypes);
     }
     return(fluentIlGenerator);
 }
Esempio n. 8
0
 public static FluentIlGenerator LdargIfClassElseLdarga(this FluentIlGenerator fluentIlGenerator, Type type,
                                                        short index)
 {
     if (type.IsValueType)
     {
         Ldarga_Auto(fluentIlGenerator, index);
     }
     else
     {
         Ldarg_Auto(fluentIlGenerator, index);
     }
     return(fluentIlGenerator);
 }