Exemple #1
0
        public virtual bool Predicate(ByRefType byRefType)
        {
            if (_defaultValue != Predicate(byRefType.ElementType))
            {
                return(!_defaultValue);
            }

            return(_defaultValue);
        }
Exemple #2
0
        public virtual bool Build(ref ByRefType byRefType)
        {
            var elementType = byRefType.ElementType;

            if (!Build(ref elementType))
            {
                return(false);
            }

            byRefType = new ByRefType(elementType);
            return(true);
        }
Exemple #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));
            }
        }
        private TypeSignature ParseType(bool parseAssembly)
        {
            var typeRef = ParseTypeRef(false);

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

            var typeSig = (TypeSignature)typeRef;

            _lexer.ReadWhiteSpaces();

            if (IsGenericArguments())
            {
                typeSig = ParseGenericTypeRef(typeRef);
                _lexer.ReadWhiteSpaces();
            }

            bool breakFlag = false;

            while (!_lexer.IsAtEndOfInput)
            {
                switch (_lexer.Peek())
                {
                case '[':
                {
                    typeSig = ParseArrayType(typeSig);
                    if (typeSig == null)
                    {
                        return(null);
                    }
                }
                break;

                case '&':
                {
                    _lexer.Move();                                     // &
                    typeSig = new ByRefType(typeSig);
                }
                break;

                case '*':
                {
                    _lexer.Move();                                     // *
                    typeSig = new PointerType(typeSig);
                }
                break;

                default:
                {
                    breakFlag = true;
                }
                break;
                }

                if (breakFlag)
                {
                    break;
                }

                _lexer.ReadWhiteSpaces();
            }

            _lexer.ReadWhiteSpaces();

            if (parseAssembly && _lexer.Peek() == ',')
            {
                _lexer.Move();

                var assembly = ParseAssembly();
                if (assembly == null)
                {
                    return(null);
                }

                while (typeRef.Owner != null && typeRef.Owner.SignatureType == SignatureType.Type)
                {
                    typeRef = (TypeReference)typeRef.Owner;
                }

                typeRef.SetOwner(assembly);
            }

            return(typeSig);
        }
 public virtual void Visit(ByRefType byRefType)
 {
     Visit(byRefType.ElementType);
 }