Exemple #1
0
        GenericInstMethodSig ResolveGenericArgs(GenericInstMethodSig sig)
        {
            var gsig = new GenericInstMethodSig();

            UpdateSigList(gsig.GenericArguments, sig.GenericArguments);
            return(gsig);
        }
 void Add(GenericInstMethodSig gsig)
 {
     if (gsig == null)
         return;
     Add(gsig.ExtraData);
     Add(gsig.GenericArguments);
 }
Exemple #3
0
 void Add(GenericInstMethodSig sig)
 {
     if (sig == null)
     {
         return;
     }
     Add(sig.GenericArguments);
 }
Exemple #4
0
        GenericInstMethodSig CreateGenericInstMethodSig(MethodBase mb)
        {
            var genMethodArgs = mb.GetGenericArguments();
            var gim           = new GenericInstMethodSig(CallingConvention.GenericInst, (uint)genMethodArgs.Length);

            foreach (var gma in genMethodArgs)
            {
                gim.GenericArguments.Add(ImportAsTypeSig(gma));
            }
            return(gim);
        }
        /// <summary>
        /// Reads a <see cref="GenericInstMethodSig"/>
        /// </summary>
        /// <param name="callingConvention">First byte of signature</param>
        /// <returns>A new <see cref="GenericInstMethodSig"/> instance</returns>
        GenericInstMethodSig ReadGenericInstMethod(CallingConvention callingConvention)
        {
            if (!reader.TryReadCompressedUInt32(out uint count))
            {
                return(null);
            }
            var sig  = new GenericInstMethodSig(callingConvention, count);
            var args = sig.GenericArguments;

            for (uint i = 0; i < count; i++)
            {
                args.Add(ReadType());
            }
            return(sig);
        }
Exemple #6
0
        bool ContainsGenericParameterInternal(GenericInstMethodSig gim)
        {
            if (gim == null)
            {
                return(false);
            }
            if (!recursionCounter.Increment())
            {
                return(false);
            }

            bool res = ContainsGenericParameter(gim.GenericArguments);

            recursionCounter.Decrement();
            return(res);
        }
Exemple #7
0
        /// <summary>
        /// Imports a <see cref="GenericInstMethodSig"/>
        /// </summary>
        /// <param name="sig">The sig</param>
        /// <returns>The imported sig or <c>null</c> if input is invalid</returns>
        public GenericInstMethodSig Import(GenericInstMethodSig sig)
        {
            if (sig == null)
            {
                return(null);
            }
            if (!recursionCounter.Increment())
            {
                return(null);
            }

            GenericInstMethodSig result = new GenericInstMethodSig(sig.GetCallingConvention(), (uint)sig.GenericArguments.Count);

            foreach (var l in sig.GenericArguments)
            {
                result.GenericArguments.Add(Import(l));
            }

            recursionCounter.Decrement();
            return(result);
        }
Exemple #8
0
 /// <summary>
 /// Checks whether <paramref name="gim"/> contains a <see cref="GenericVar"/> or a
 /// <see cref="GenericMVar"/>.
 /// </summary>
 /// <param name="gim">Generic method signature</param>
 /// <returns><c>true</c> if <paramref name="gim"/> contains a <see cref="GenericVar"/>
 /// or a <see cref="GenericMVar"/>.</returns>
 public static bool ContainsGenericParameter(GenericInstMethodSig gim)
 {
     return(new TypeHelper().ContainsGenericParameterInternal(gim));
 }
Exemple #9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="method">The generic method</param>
 /// <param name="sig">The instantiated method sig</param>
 public MethodSpecUser(IMethodDefOrRef method, GenericInstMethodSig sig)
 {
     this.method        = method;
     this.instantiation = sig;
 }
Exemple #10
0
 void Add(GenericInstMethodSig sig)
 {
     if (sig == null)
         return;
     Add(sig.GenericArguments);
 }
Exemple #11
0
		bool ContainsGenericParameterInternal(GenericInstMethodSig gim) {
			if (gim == null)
				return false;
			if (!recursionCounter.Increment())
				return false;

			bool res = ContainsGenericParameter(gim.GenericArguments);

			recursionCounter.Decrement();
			return res;
		}
Exemple #12
0
		/// <summary>
		/// Checks whether <paramref name="gim"/> contains a <see cref="GenericVar"/> or a
		/// <see cref="GenericMVar"/>.
		/// </summary>
		/// <param name="gim">Generic method signature</param>
		/// <returns><c>true</c> if <paramref name="gim"/> contains a <see cref="GenericVar"/>
		/// or a <see cref="GenericMVar"/>.</returns>
		public static bool ContainsGenericParameter(GenericInstMethodSig gim) {
			return new TypeHelper().ContainsGenericParameterInternal(gim);
		}
		public static GenericInstMethodSig Create(GenericInstMethodSig sig, GenericInstSig git) {
			if (git == null)
				return sig;
			return Create(sig, git.GenericArguments);
		}
Exemple #14
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="method">The generic method</param>
 /// <param name="sig">The instantiated method sig</param>
 public MethodSpecUser(IMethodDefOrRef method, GenericInstMethodSig sig)
 {
     this.method = method;
     this.instantiation = sig;
 }
Exemple #15
0
		List<IMethod> GetMethods(TypeDef declaringType, BabelMethodreference babelMethodRef) {
			var methods = new List<IMethod>();

			var gis = babelMethodRef.DeclaringType as GenericInstSig;
			var gim = babelMethodRef.GenericArguments;
			foreach (var method in declaringType.Methods) {
				if (CompareMethod(GenericArgsSubstitutor.Create(method, gis, gim), babelMethodRef)) {
					if (!babelMethodRef.IsGenericMethod)
						methods.Add(memberRefConverter.Convert(method));
					else {
						var gim2 = new GenericInstMethodSig(babelMethodRef.GenericArguments);
						var ms = module.UpdateRowId(new MethodSpecUser(memberRefConverter.Convert(method), gim2));
						methods.Add(ms);
					}
				}
			}

			return methods;
		}
Exemple #16
0
 /// <summary>
 /// Gets the generic arguments
 /// </summary>
 /// <param name="sig">this</param>
 /// <returns>All generic arguments</returns>
 public static IList <TypeSig> GetGenericArguments(this GenericInstMethodSig sig)
 {
     return(sig == null ? new List <TypeSig>() : sig.GenericArguments);
 }
		public static GenericInstMethodSig Create(GenericInstMethodSig sig, IList<TypeSig> genericArgs) {
			if (sig == null || genericArgs == null || genericArgs.Count == 0)
				return sig;
			return new GenericArgsSubstitutor(genericArgs).Create(sig);
		}
		GenericInstMethodSig Create(GenericInstMethodSig sig) {
			var newSig = new GenericInstMethodSig();
			for (int i = 0; i < sig.GenericArguments.Count; i++)
				newSig.GenericArguments.Add(Create2(sig.GenericArguments[i]));
			return updated ? newSig : sig;
		}
Exemple #19
0
 /// <summary>
 /// Gets the generic arguments
 /// </summary>
 /// <param name="sig">this</param>
 /// <returns>All generic arguments</returns>
 public static IList <TypeSig> GetGenericArguments(this GenericInstMethodSig sig)
 {
     return(sig == null?ThreadSafeListCreator.Create <TypeSig>() : sig.GenericArguments);
 }
Exemple #20
0
		void Hash(GenericInstMethodSig sig) {
			if (sig == null)
				return;

			hasher.Hash((byte)sig.GetCallingConvention());
			foreach (var ga in sig.GetGenericArguments())
				Hash(ga);
		}