Beispiel #1
0
        static VTableSlot ResolveSlot(TypeDef openType, VTableSlot slot, IList <TypeSig> genArgs)
        {
            MethodSig newSig  = GenericArgumentResolver.Resolve(slot.Signature.MethodSig, genArgs);
            TypeSig   newDecl = slot.MethodDefDeclType;

            newDecl = new SigComparer().Equals(newDecl, openType)
                ? new GenericInstSig((ClassOrValueTypeSig)openType.ToTypeSig(), genArgs.ToArray())
                : GenericArgumentResolver.Resolve(newDecl, genArgs);
            return(new VTableSlot(newDecl, slot.MethodDef, slot.DeclaringType, new VTableSignature(newSig, slot.Signature.Name), slot.Overrides));
        }
Beispiel #2
0
        public static VTableSignature FromMethod(IMethod method)
        {
            MethodSig sig      = method.MethodSig;
            var       declType = method.DeclaringType.ToTypeSig();

            if (declType is GenericInstSig)
            {
                sig = GenericArgumentResolver.Resolve(sig, ((GenericInstSig)declType).GenericArguments);
            }
            return(new VTableSignature(sig, method.Name));
        }
		/// <summary>
		///     Resolves the method signature with the specified generic arguments.
		/// </summary>
		/// <param name="methodSig">The method signature.</param>
		/// <param name="typeGenArgs">The type generic arguments.</param>
		/// <returns>Resolved method signature.</returns>
		/// <exception cref="System.ArgumentException">No generic arguments to resolve.</exception>
		public static MethodSig Resolve(MethodSig methodSig, IList<TypeSig> typeGenArgs) {
			if (typeGenArgs == null)
				throw new ArgumentException("No generic arguments to resolve.");

			var resolver = new GenericArgumentResolver();
			resolver.genericArguments = new GenericArguments();
			resolver.recursionCounter = new RecursionCounter();

			if (typeGenArgs != null)
				resolver.genericArguments.PushTypeArgs(typeGenArgs);

			return resolver.ResolveGenericArgs(methodSig);
		}
        /// <summary>
        ///     Resolves the method signature with the specified generic arguments.
        /// </summary>
        /// <param name="methodSig">The method signature.</param>
        /// <param name="typeGenArgs">The type generic arguments.</param>
        /// <returns>Resolved method signature.</returns>
        /// <exception cref="System.ArgumentException">No generic arguments to resolve.</exception>
        public static MethodSig Resolve(MethodSig methodSig, IList <TypeSig> typeGenArgs)
        {
            if (typeGenArgs == null)
            {
                throw new ArgumentException("No generic arguments to resolve.");
            }

            var resolver = new GenericArgumentResolver();

            resolver._genericArguments = new GenericArguments();
            resolver._recursionCounter = new RecursionCounter();
            resolver._genericArguments.PushTypeArgs(typeGenArgs);

            return(resolver.ResolveGenericArgs(methodSig));
        }
Beispiel #5
0
        static VTable ResolveGenericArgument(TypeDef openType, GenericInstSig genInst, VTable vTable)
        {
            Debug.Assert(new SigComparer().Equals(openType, vTable.Type));
            var ret = new VTable(genInst);

            foreach (VTableSlot slot in vTable.Slots)
            {
                ret.Slots.Add(ResolveSlot(openType, slot, genInst.GenericArguments));
            }
            foreach (KeyValuePair <TypeSig, IList <VTableSlot> > iface in vTable.InterfaceSlots)
            {
                ret.InterfaceSlots.Add(GenericArgumentResolver.Resolve(iface.Key, genInst.GenericArguments),
                                       iface.Value.Select(slot => ResolveSlot(openType, slot, genInst.GenericArguments)).ToList());
            }
            return(ret);
        }
        // Token: 0x0600022C RID: 556 RVA: 0x0001F2CC File Offset: 0x0001D4CC
        public static TypeSig Resolve(TypeSig typeSig, IList <TypeSig> typeGenArgs)
        {
            if (typeGenArgs == null)
            {
                throw new ArgumentException("No generic arguments to resolve.");
            }
            GenericArgumentResolver resolver = default(GenericArgumentResolver);

            resolver.genericArguments = new GenericArguments();
            resolver.recursionCounter = default(RecursionCounter);
            if (typeGenArgs != null)
            {
                resolver.genericArguments.PushTypeArgs(typeGenArgs);
            }
            return(resolver.ResolveGenericArgs(typeSig));
        }
Beispiel #7
0
        private static VTable ResolveGenericArgument(TypeDef openType, GenericInstSig genInst, VTable vTable)
        {
            Debug.Assert(openType == vTable.Type);
            var ret = new VTable(openType);

            ret.GenericArguments = genInst.GenericArguments;
            foreach (VTableSlot slot in vTable.Slots)
            {
                MethodSig newSig  = GenericArgumentResolver.Resolve(slot.Signature.MethodSig, genInst.GenericArguments);
                TypeSig   newDecl = slot.DeclaringType;
                if (new SigComparer().Equals(newDecl, openType))
                {
                    newDecl = new GenericInstSig((ClassOrValueTypeSig)openType.ToTypeSig(), genInst.GenericArguments.ToArray());
                }
                else
                {
                    newDecl = GenericArgumentResolver.Resolve(newDecl, genInst.GenericArguments);
                }
                ret.Slots.Add(new VTableSlot(ret, slot.MethodDef, newDecl, new VTableSignature(genInst, newSig, slot.Signature.Name)).Override(slot));
            }
            return(ret);
        }