private ILEmitter EmitHashAsSortedArray(ILEmitter il, LocalBuilder enumerable, LocalBuilder hash)
        {
            var hasCustomComparer = _configuration.HasCustomComparer(_elementType);

            il.EmitArraySorting(hasCustomComparer, _elementType, enumerable);

            var arrayType = _elementType.MakeArrayType();

            return(_arrayHashEmitter.Emit(il, arrayType, enumerable, hash));
        }
        private ILEmitter EmitCompareAsSortedArrays(ILEmitter il, Label gotoNext, LocalBuilder x, LocalBuilder y)
        {
            var hasCustomComparer = _configuration.HasCustomComparer(_elementType);

            il.EmitArraySorting(hasCustomComparer, _elementType, x, y);

            var arrayType = _elementType.MakeArrayType();

            return(_arrayComparisonEmitter.EmitCompareArrays(il, arrayType, _variable.OwnerType, x, y, gotoNext));
        }
        public ILEmitter Emit(ILEmitter il, Label gotoNext)
        {
            var arrayType = _variable.VariableType;

            var(arrayX, arrayY) = _arrayComparisonEmitter.EmitLoad(_variable, il, gotoNext);

            if (_configuration.Get(_variable.OwnerType).IgnoreCollectionOrder)
            {
                var elementType       = arrayType.GetElementType();
                var hasCustomComparer = _configuration.HasCustomComparer(elementType);
                il.EmitArraySorting(hasCustomComparer, elementType, arrayX, arrayY);
            }

            return(_arrayComparisonEmitter.EmitCompareArrays(il, arrayType, _variable.OwnerType, arrayX, arrayY, gotoNext));
        }
Пример #4
0
        public ILEmitter Emit(ILEmitter il, LocalBuilder hash)
        {
            var arrayType = _variable.VariableType;

            il.Emit(_variable.Load(Arg.Input)) // load array
            .Stloc(arrayType, out var array)
            .Brtrue_S(Ldloc(array), out var begin)
            .Ldc_I4(0)
            .Br(out var end)
            .MarkLabel(begin);

            if (_configuration.IgnoreCollectionOrder)
            {
                il.EmitArraySorting(_hasCustomComparer, arrayType.GetElementType(), array);
            }

            return(_arrayHashEmitter.Emit(il, arrayType, array, hash).MarkLabel(end));
        }