Exemplo n.º 1
0
        protected bool Equals(IFieldSignature x, IFieldSignature y, bool canIgnoreOwner)
        {
            if (x == y)
            {
                return(true);
            }

            if (x == null || y == null)
            {
                return(false);
            }

            if (x.Name != y.Name)
            {
                return(false);
            }

            if (!Equals(x.FieldType, y.FieldType, false))
            {
                return(false);
            }

            if (!canIgnoreOwner || (_flags & SignatureComparisonFlags.IgnoreMemberOwner) != SignatureComparisonFlags.IgnoreMemberOwner)
            {
                if (!Equals(x.Owner, y.Owner, canIgnoreOwner))
                {
                    return(false);
                }
            }

            return(true);
        }
        private bool EqualsField(IFieldSignature x, IFieldSignature y)
        {
            if (x == y)
            {
                return(true);
            }

            if (x == null || y == null)
            {
                return(false);
            }

            if (x.Name != y.Name)
            {
                return(false);
            }

            if (!EqualsType(x.FieldType, y.FieldType))
            {
                return(false);
            }

            if (!EqualsType(x.Owner, y.Owner))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        private void WriteField(ref int pos, IFieldSignature field)
        {
            _blob.Write(ref pos, (byte)SignatureType.Field);
            WriteString(ref pos, field.Name);

            var  owner      = field.Owner;
            bool writeOwner = (owner != null);

            _blob.Write(ref pos, (bool)writeOwner);

            int addLength = 4;

            if (writeOwner)
            {
                addLength += 4;
            }

            _blob.Length += addLength;

            if (writeOwner)
            {
                WriteReferenced(ref pos, owner);
            }

            WriteReferenced(ref pos, field.FieldType);
        }
        public static string ToString(this IFieldSignature fieldSig, IModule module = null, SignaturePrintingFlags flags = SignaturePrintingFlags.None)
        {
            var printer = new SignaturePrinter(flags);

            printer.PrintField(fieldSig, module);

            return(printer.ToString());
        }
        internal bool Equals(IFieldSignature x, IFieldSignature y)
        {
            if (x.Name != y.Name)
            {
                return(false);
            }

            if (!EqualsType(x.FieldType, y.FieldType))
            {
                return(false);
            }

            return(true);
        }
        public IField Resolve(IFieldSignature fieldSig, ICodeNode context, bool throwOnFailure = false)
        {
            var field = ResolveField(fieldSig, context.Module, context);

            if (field == null)
            {
                if (throwOnFailure)
                {
                    throw new ResolveReferenceException(string.Format(SR.FieldResolveError, fieldSig.ToString()));
                }

                return(null);
            }

            return(field);
        }
Exemplo n.º 7
0
        protected int GetHashCode(IFieldSignature obj, bool canIgnoreOwner)
        {
            int hashCode = 0x8000;

            if (obj.Name != null)
            {
                hashCode ^= obj.Name.GetHashCode();
            }

            if (!canIgnoreOwner || (_flags & SignatureComparisonFlags.IgnoreMemberOwner) != SignatureComparisonFlags.IgnoreMemberOwner)
            {
                var owner = obj.Owner;
                if (owner != null)
                {
                    hashCode ^= GetHashCode(owner, canIgnoreOwner);
                }
            }

            return(hashCode);
        }
Exemplo n.º 8
0
        public void PrintField(IFieldSignature fieldSig, IModule module)
        {
            if ((_flags & SignaturePrintingFlags.IgnoreMemberOwner) != SignaturePrintingFlags.IgnoreMemberOwner)
            {
                var owner = fieldSig.Owner;
                if (owner != null)
                {
                    PrintType(owner, module);
                }
                else
                {
                    _builder.Append(CodeModelUtils.GlobalTypeName);
                }

                _builder.Append("::");
            }

            PrintIdentifier(fieldSig.Name);
            _builder.Append(" : ");
            PrintType(fieldSig.FieldType, module, false);
        }
        protected IField ResolveField(IFieldSignature fieldSig, IModule context, ICodeNode genericContext)
        {
            var ownerType = ResolveType(fieldSig.Owner, context, genericContext);

            if (ownerType == null)
            {
                return(null);
            }

            var comparer = new ResolveSignatureComparer(context, ownerType.Module);

            // Find
            foreach (var field in ownerType.Fields)
            {
                if (comparer.Equals(fieldSig, field.DeclaringField))
                {
                    return(field);
                }
            }

            return(null);
        }
 public static IField Resolve(this IFieldSignature fieldSig, ICodeNode context, bool throwOnFailure = false)
 {
     return(context.AssemblyManager.Resolve(fieldSig, context, throwOnFailure));
 }
Exemplo n.º 11
0
 public int GetHashCode(IFieldSignature obj)
 {
     return(GetHashCode(obj, true));
 }
Exemplo n.º 12
0
 public bool Equals(IFieldSignature x, IFieldSignature y)
 {
     return(Equals(x, y, true));
 }