public static ILEmitter EmitCheckNullablesForValue(this ILEmitter il, ILEmitterFunc nullableX, ILEmitterFunc nullableY, Type nullableType, Label ifBothNull)
        {
            var hasValueMethod = nullableType.GetPropertyGetter("HasValue");

            return(il.CallMethod(hasValueMethod, nullableY)
                   .Stloc(typeof(bool), out var secondHasValue)
                   .CallMethod(hasValueMethod, nullableX)
                   .Brtrue_S(out var ifFirstHasValue)
                   .Ldloc(secondHasValue)
                   .Brfalse(ifBothNull)
                   .Ret(0)
                   .MarkLabel(ifFirstHasValue)
                   .Ldloc(secondHasValue)
                   .Brtrue_S(out var next)
                   .Ret(0)
                   .MarkLabel(next));
        }
 public static ILEmitter EmitReferenceComparison(this ILEmitter il, ILEmitterFunc loadX, ILEmitterFunc loadY, ILEmitterFunc ifEqual) =>
 il.Bne_Un_S(loadX, loadY, out var checkX)
 .Emit(ifEqual)
 .MarkLabel(checkX)
 .Emit(loadX)
 .Brtrue_S(out var checkY)
示例#3
0
 public static ILEmitter Cast <T>(this ILEmitter self, ILEmitterFunc value) => value(self).Cast(typeof(T));