Ejemplo n.º 1
0
        internal int CompareTo(DelegateCreationInfo other, TypeSystemComparer comparer)
        {
            var compare = _targetKind - other._targetKind;

            if (compare != 0)
            {
                return(compare);
            }

            compare = comparer.Compare(TargetMethod, other.TargetMethod);
            if (compare != 0)
            {
                return(compare);
            }

            compare = comparer.Compare(Constructor.Method, other.Constructor.Method);
            if (compare != 0)
            {
                return(compare);
            }

            if (_constrainedType != null && other._constrainedType != null)
            {
                compare = comparer.Compare(_constrainedType, other._constrainedType);
                if (compare != 0)
                {
                    return(compare);
                }
            }
            else
            {
                if (_constrainedType != null)
                {
                    return(1);
                }
                if (other._constrainedType != null)
                {
                    return(-1);
                }
            }

            if (Thunk == other.Thunk)
            {
                return(0);
            }

            if (Thunk == null)
            {
                return(-1);
            }

            if (other.Thunk == null)
            {
                return(1);
            }

            return(comparer.Compare(Thunk.Method, other.Thunk.Method));
        }
Ejemplo n.º 2
0
        public DelegateCreationInfo GetDelegateCtor(TypeDesc delegateType, MethodDesc target, bool followVirtualDispatch)
        {
            // If we're creating a delegate to a virtual method that cannot be overriden, devirtualize.
            // This is not just an optimization - it's required for correctness in the presence of sealed
            // vtable slots.
            if (followVirtualDispatch && (target.IsFinal || target.OwningType.IsSealed()))
            {
                followVirtualDispatch = false;
            }

            return(DelegateCreationInfo.Create(delegateType, target, NodeFactory, followVirtualDispatch));
        }
Ejemplo n.º 3
0
 public DelegateCreationInfo GetDelegateCtor(TypeDesc delegateType, MethodDesc target, bool followVirtualDispatch)
 {
     return(DelegateCreationInfo.Create(delegateType, target, NodeFactory, followVirtualDispatch));
 }
Ejemplo n.º 4
0
 public DelegateCreationInfo GetDelegateCtor(TypeDesc delegateType, MethodDesc target)
 {
     return(DelegateCreationInfo.Create(delegateType, target, NodeFactory));
 }