Beispiel #1
0
        public virtual bool Build(ref GenericTypeReference genericTypeRef)
        {
            bool changed = false;

            var typeRef = genericTypeRef.DeclaringType;

            changed |= Build(ref typeRef);

            var genericArguments = new TypeSignature[genericTypeRef.GenericArguments.Count];

            for (int i = 0; i < genericArguments.Length; i++)
            {
                var genericArgument = genericTypeRef.GenericArguments[i];
                changed            |= Build(ref genericArgument);
                genericArguments[i] = genericArgument;
            }

            if (!changed)
            {
                return(false);
            }

            genericTypeRef = new GenericTypeReference(typeRef, genericArguments);
            return(true);
        }
Beispiel #2
0
        public virtual void Visit(GenericTypeReference genericTypeRef)
        {
            Visit(genericTypeRef.DeclaringType);

            for (int i = 0; i < genericTypeRef.GenericArguments.Count; i++)
            {
                Visit(genericTypeRef.GenericArguments[i]);
            }
        }
Beispiel #3
0
        internal static TypeSignature Load(IBinaryAccessor accessor, Module module)
        {
            int elementType = accessor.ReadCompressedInteger();

            switch (elementType)
            {
            case Metadata.ElementType.Class:
                return(TypeReference.LoadClass(accessor, module));

            case Metadata.ElementType.ValueType:
                return(TypeReference.LoadValueType(accessor, module));

            case Metadata.ElementType.ByRef:
                return(ByRefType.LoadByRef(accessor, module));

            case Metadata.ElementType.Ptr:
                return(PointerType.LoadPtr(accessor, module));

            case Metadata.ElementType.FnPtr:
                return(FunctionPointer.LoadFnPtr(accessor, module));

            case Metadata.ElementType.Array:
                return(ArrayType.LoadArray(accessor, module));

            case Metadata.ElementType.SzArray:
                return(ArrayType.LoadSzArray(accessor, module));

            case Metadata.ElementType.Var:
                return(GenericParameterType.LoadVar(accessor, module));

            case Metadata.ElementType.MVar:
                return(GenericParameterType.LoadMVar(accessor, module));

            case Metadata.ElementType.GenericInst:
                return(GenericTypeReference.LoadGeneric(accessor, module));

            case Metadata.ElementType.CModOpt:
                return(CustomModifier.LoadModOpt(accessor, module));

            case Metadata.ElementType.CModReqD:
                return(CustomModifier.LoadModReq(accessor, module));

            case Metadata.ElementType.Pinned:
                return(PinnedType.LoadPinned(accessor, module));

            default:
                return(TypeReference.GetPrimitiveType(elementType, module.Assembly));
            }
        }
Beispiel #4
0
        public virtual bool Predicate(GenericTypeReference genericTypeRef)
        {
            if (_defaultValue != Predicate(genericTypeRef.DeclaringType))
            {
                return(!_defaultValue);
            }

            for (int i = 0; i < genericTypeRef.GenericArguments.Count; i++)
            {
                if (_defaultValue != Predicate(genericTypeRef.GenericArguments[i]))
                {
                    return(!_defaultValue);
                }
            }

            return(_defaultValue);
        }