Esempio n. 1
0
        public ProofOutcome IsNonNull(APC pc, V variable)
        {
            Domain <E, V> domain;

            if (!PreStateLookup(pc, out domain) || domain.NonNulls.IsBottom)
            {
                return(ProofOutcome.Bottom);
            }
            if (domain.IsNonNull(variable))
            {
                return(ProofOutcome.True);
            }
            if (ContextProvider.ValueContext.IsZero(pc, variable) || domain.IsNull(variable))
            {
                return(ProofOutcome.False);
            }

            FlatDomain <TypeNode> aType = ContextProvider.ValueContext.GetType(pc, variable);

            if (aType.IsNormal && MetaDataProvider.IsManagedPointer(aType.Concrete))
            {
                return(ProofOutcome.True);
            }

            return(ProofOutcome.Top);
        }
Esempio n. 2
0
        public override bool TrySetType(TypeNode expectedType, IMetaDataProvider metaDataProvider, out TypeNode resultType)
        {
            switch (this.Element)
            {
            case SpecialPathElementKind.Length:
                this.castTo = metaDataProvider.IsArray(expectedType) ||
                              metaDataProvider.System_String.Equals(expectedType)
                                                ? ""
                                                : "System.Array";
                resultType = metaDataProvider.System_Int32;
                return(true);

            case SpecialPathElementKind.Deref:
                if (metaDataProvider.IsManagedPointer(expectedType))
                {
                    TypeNode type = metaDataProvider.ElementType(expectedType);
                    this.type  = type;
                    resultType = type;
                    return(true);
                }
                resultType = default(TypeNode);
                return(false);

            default:
                resultType = default(TypeNode);
                return(false);
            }
        }
Esempio n. 3
0
        public ParameterPathElement(Parameter p, string description,
                                    SymFunction c, IMetaDataProvider metaDataProvider)
            : base(p, description, c)
        {
            TypeNode type = metaDataProvider.ParameterType(p);

            ResultType = metaDataProvider.ManagedPointer(type);

            if (metaDataProvider.IsManagedPointer(type))
            {
                this.isManagedPointer = true;
            }
        }
Esempio n. 4
0
        public override bool TrySetType(TypeNode expectedType, IMetaDataProvider metaDataProvider, out TypeNode resultType)
        {
            if (typeof(T) == typeof(Parameter))
            {
                var      p    = (Parameter)(object)this.Element;
                TypeNode type = metaDataProvider.ParameterType(p);
                this.isManagedPointer = metaDataProvider.IsManagedPointer(type);
                ResultType            = resultType = metaDataProvider.ManagedPointer(type);
                return(true);
            }

            if (typeof(T) == typeof(Field))
            {
                var      f    = (Field)(object)this.Element;
                TypeNode type = metaDataProvider.FieldType(f);
                this.isStatic         = metaDataProvider.IsStatic(f);
                this.isManagedPointer = metaDataProvider.IsManagedPointer(type);
                ResultType            = resultType = metaDataProvider.ManagedPointer(type);

                TypeNode declaringType = metaDataProvider.DeclaringType(f);
                if (metaDataProvider.IsManagedPointer(expectedType))
                {
                    expectedType = metaDataProvider.ElementType(expectedType);
                }
                expectedType = metaDataProvider.Unspecialized(expectedType);

                if (!metaDataProvider.IsStatic(f) && declaringType.Equals(expectedType) &&
                    (!metaDataProvider.DerivesFrom(expectedType, declaringType) ||
                     !metaDataProvider.IsProtected(f) && !metaDataProvider.IsPublic(f)))
                {
                    this.castTo = metaDataProvider.FullName(declaringType);
                }

                return(true);
            }

            if (typeof(T) == typeof(Local))
            {
                var      local = (Local)(object)this.Element;
                TypeNode type  = metaDataProvider.LocalType(local);
                this.isManagedPointer = metaDataProvider.IsManagedPointer(type);
                ResultType            = resultType = metaDataProvider.ManagedPointer(type);

                return(true);
            }

            if (typeof(T) == typeof(Method))
            {
                var method = (Method)(object)this.Element;
                ResultType = resultType = !IsAddressOf
                                                                ? metaDataProvider.ReturnType(method)
                                                                : metaDataProvider.ManagedPointer(metaDataProvider.ReturnType(method));

                if (metaDataProvider.IsManagedPointer(expectedType))
                {
                    expectedType = metaDataProvider.ElementType(expectedType);
                }
                expectedType = metaDataProvider.Unspecialized(expectedType);

                TypeNode declaringType = metaDataProvider.DeclaringType(method);
                if (!metaDataProvider.IsStatic(method) && declaringType.Equals(expectedType) &&
                    (!metaDataProvider.DerivesFrom(expectedType, declaringType) ||
                     !metaDataProvider.IsProtected(method) && !metaDataProvider.IsPublic(method)))
                {
                    this.castTo = metaDataProvider.FullName(declaringType);
                }

                return(true);
            }

            ResultType = resultType = default(TypeNode);
            return(false);
        }