Esempio n. 1
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. 2
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);
        }