Ejemplo n.º 1
0
        public override Domain <E, V> Entry(APC pc, Method method, Domain <E, V> data)
        {
            APC                    at         = ContextProvider.MethodContext.CFG.Next(pc);
            Domain <E, V>          domain     = data;
            IIndexable <Parameter> parameters = MetaDataProvider.Parameters(method);
            TypeNode               eventArgsType;
            bool                   systemType = MetaDataProvider.TryGetSystemType("System.EventArgs", out eventArgsType);

            for (int i = 0; i < parameters.Count; i++)
            {
                Parameter p     = parameters [i];
                TypeNode  pType = MetaDataProvider.ParameterType(p);
                if (MetaDataProvider.IsManagedPointer(pType))
                {
                    V sv;
                    if (ContextProvider.ValueContext.TryParameterValue(at, p, out sv))
                    {
                        domain = AssumeNonNull(sv, domain);
                    }
                }
                else
                {
                    V sv;
                    if (i == 0 && parameters.Count == 1 && MetaDataProvider.IsArray(pType) &&
                        MetaDataProvider.Name(method) == "Main" && MetaDataProvider.IsStatic(method) &&
                        ContextProvider.ValueContext.TryParameterValue(pc, p, out sv))
                    {
                        domain = AssumeNonNull(sv, domain);
                    }
                }
            }
            V sv1;

            if (systemType && parameters.Count == 2 && MetaDataProvider.Equal(MetaDataProvider.System_Object, MetaDataProvider.ParameterType(parameters [0])) &&
                MetaDataProvider.DerivesFrom(MetaDataProvider.ParameterType(parameters [1]), eventArgsType) &&
                ContextProvider.ValueContext.TryParameterValue(pc, parameters [1], out sv1))
            {
                domain = AssumeNonNull(sv1, domain);
            }
            if (!MetaDataProvider.IsStatic(method) && ContextProvider.ValueContext.TryParameterValue(pc, MetaDataProvider.This(method), out sv1))
            {
                domain = AssumeNonNull(sv1, domain);
            }

            return(domain);
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
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);
        }