Ejemplo n.º 1
0
 private EnumDefined <BoxedVariable <Variable>, Type, BoxedExpression> AssumeIfEnumType(Type type, Variable v, EnumDefined <BoxedVariable <Variable>, Type, BoxedExpression> data)
 {
     if (this.DecoderForMetaData.IsEnumWithoutFlagAttribute(type))
     {
         return(data.AssumeCondition(type, ToBoxedVariable(v)));
     }
     return(data);
 }
Ejemplo n.º 2
0
                Assume(APC pc, string tag, Variable source, object provenance, EnumDefined <BoxedVariable <Variable>, Type, BoxedExpression> data)
                {
                    if (tag != "false")
                    {
                        return(data.AssumeCondition(ToBoxedVariable(source)));
                    }
                    else
                    {
                        // try to see if it is sv == 0
                        var             bExp = ToBoxedExpression(pc, source);
                        BoxedExpression left;
                        int             k;
                        Variable        underlying;
                        if (bExp.IsCheckExp1EqConst(out left, out k) && k == 0 && left.TryGetFrameworkVariable(out underlying))
                        {
                            return(data.AssumeCondition(ToBoxedVariable(underlying)));
                        }

                        return(data);
                    }
                }
Ejemplo n.º 3
0
                public override EnumDefined <BoxedVariable <Variable>, Type, BoxedExpression> Entry(APC pc, Method method, EnumDefined <BoxedVariable <Variable>, Type, BoxedExpression> data)
                {
                    foreach (var param in this.DecoderForMetaData.Parameters(method).Enumerate())
                    {
                        Variable symb;
                        if (this.Context.ValueContext.TryParameterValue(Context.MethodContext.CFG.Post(pc), param, out symb))
                        {
                            var typeForParam = this.Context.ValueContext.GetType(Context.MethodContext.CFG.Post(pc), symb);
                            if (typeForParam.IsNormal && this.DecoderForMetaData.IsEnumWithoutFlagAttribute(typeForParam.Value))
                            {
                                data = data.AssumeCondition(typeForParam.Value, ToBoxedVariable(symb));
                            }
                        }
                    }

                    return(data);
                }
Ejemplo n.º 4
0
                public override EnumDefined <BoxedVariable <Variable>, Type, BoxedExpression> Call <TypeList, ArgList>(APC pc, Method method,
                                                                                                                       bool tail, bool virt, TypeList extraVarargs, Variable dest, ArgList args, EnumDefined <BoxedVariable <Variable>, Type, BoxedExpression> data)
                {
                    var  methodname = this.DecoderForMetaData.Name(method);
                    var  nsName     = this.DecoderForMetaData.Namespace(this.DecoderForMetaData.DeclaringType(method));
                    Type type;

                    if (nsName != null && methodname != null &&
                        nsName.Equals("System") && methodname.Equals("GetTypeFromHandle"))
                    {
                        Type runtimeType;
                        if (Context.ValueContext.IsRuntimeType(this.Context.MethodContext.CFG.Post(pc), dest, out runtimeType)) // Get the type
                        {
                            this.lastTypeForGetTypeFromHandle[dest] = runtimeType;
                        }

                        return(data);
                    }

                    if (args.Count == 2 && methodname == "IsDefined" && this.lastTypeForGetTypeFromHandle.TryGetValue(args[0], out type))
                    {
                        data = data.AssumeTypeIff(ToBoxedVariable(dest), type, ToBoxedVariable(args[1]));

                        Variable unboxed;
                        if (this.Context.ValueContext.TryUnbox(pc, args[1], out unboxed))
                        {
                            data = data.AssumeTypeIff(ToBoxedVariable(dest), type, ToBoxedVariable(unboxed));
                        }

                        return(data);
                    }

                    var destType = this.Context.ValueContext.GetType(this.MethodDriver.CFG.Post(pc), dest);

                    if (destType.IsNormal && this.DecoderForMetaData.IsEnumWithoutFlagAttribute(destType.Value))
                    {
                        data = data.AssumeCondition(destType.Value, ToBoxedVariable(dest));
                    }
                    return(data);
                }
Ejemplo n.º 5
0
 Assert(APC pc, string tag, Variable condition, object provenance, EnumDefined <BoxedVariable <Variable>, Type, BoxedExpression> data)
 {
     return(data.AssumeCondition(ToBoxedVariable(condition)));
 }