Пример #1
0
        public override Domain Stfld(APC pc, Field field, bool @volatile, Variable obj, Variable value, Domain data)
        {
            IDecodeMetaData <Local, Parameter, Method, Field, Property, Type, Attribute, Assembly> mdDecoder = this.methodDriver.MetaDataDecoder;
            Expression exp = this.context.Refine(pc, value);
            IFullExpressionDecoder <Type, Expression> fullExpDecoder =
                ExternalExpressionDecoder.Create(mdDecoder, this.context);
            // BoxedExpressionDecoder beDecoder = BoxedExpressionDecoder.Decoder(fullExpDecoder);
            BoxedExpression        be         = BoxedExpression.For(exp, fullExpDecoder);
            IIndexable <Parameter> parameters = mdDecoder.Parameters(this.context.CurrentMethod);

            for (int i = 0, n = parameters.Count; i < n; i++)
            {
                Variable v;
                if (this.context.TryParameterValue(pc, parameters[i], out v))
                {
                    if (v.Equals(value))
                    {
                        if (this.fieldsHold == null)
                        {
                            this.fieldsHold = FunctionalMap <string, int> .Empty;
                        }
                        this.fieldsHold = (FunctionalMap <string, int>) this.fieldsHold.Add(mdDecoder.Name(parameters[i]), i + 1);
                        break;
                    }
                }
            }
            return(base.Stfld(pc, field, @volatile, obj, value, data));
        }
Пример #2
0
 public GenericValueAnalysisCacher(
     ExpressionCacheMode expCachingMode,
     IExpressionContext <Local, Parameter, Method, Field, Type, Expression, Variable> context,
     IFullExpressionDecoder <Type, Variable, Expression> decoder
     )
 {
     this.ExpCachingMode = expCachingMode;
     this.Context        = context;
     this.Decoder        = decoder;
 }
Пример #3
0
                bool IsEnumeratorStatePredicate(APC pc, Variable condition, out int stateValue, out bool OpIsEq)
                {
                    stateValue = -100;
                    OpIsEq     = false;
                    IFullExpressionDecoder <Type, Variable, Expression> decoder = this.mdriver.ExpressionDecoder;
                    Expression     exp = this.context.ExpressionContext.Refine(pc, condition);
                    BinaryOperator op;
                    Expression     left, right;

                    if (decoder.IsBinaryOperator(exp, out op, out left, out right))
                    {
                        if (op == BinaryOperator.Ceq || op == BinaryOperator.Cne_Un || op == BinaryOperator.Cobjeq)
                        {
                            if (op == BinaryOperator.Cne_Un)
                            {
                                OpIsEq = false;
                            }
                            else
                            {
                                OpIsEq = true;
                            }
                            object o;
                            if (decoder.IsVariable(left, out o))
                            {
                                string path = this.context.ValueContext.AccessPath(pc, (Variable)o);
                                if (path != null)
                                {
                                    if (path.Contains(".<>") && path.EndsWith("state"))
                                    {
                                        object value; Type type;
                                        if (decoder.IsConstant(right, out value, out type))
                                        {
                                            if (type.Equals(this.mdriver.MetaDataDecoder.System_UInt32) || type.Equals(this.mdriver.MetaDataDecoder.System_Int32))
                                            {
                                                stateValue = (int)value;
                                                return(true);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    return(false);
                }
Пример #4
0
                    public ToBoxedExpressionConverter(
                        ExpressionCacheMode mode,
                        IExpressionContext <Local, Parameter, Method, Field, Type, Expression, Variable> context,
                        IFullExpressionDecoder <Type, Variable, Expression> outdecoder)
                    {
                        Contract.Requires(context != null);

                        this.cachingMode = mode;
                        this.context     = context.ExpressionContext;
                        this.outdecoder  = outdecoder;

                        if (mode == ExpressionCacheMode.Mem)
                        {
                            this.weakrefMap = new Dictionary <Pair <APC, Variable>, WeakReference>();
                            Contract.Assert((this.weakrefMap != null) == (this.fullMap == null), "Help the WP of Clousot prove the invariant");
                        }
                        else if (mode == ExpressionCacheMode.Time)
                        {
                            this.fullMap = new Dictionary <Pair <APC, Variable>, BoxedExpression>();
                        }
                    }
Пример #5
0
 public BoxedExpressionDecoder(IFullExpressionDecoder <TVar, TExpr> externalDecoder)
 {
     ExternalDecoder = externalDecoder;
 }
 public BoxedExpressionDecoder(IFullExpressionDecoder <Type, Variable, ExternalExpression> outdecoder)
 {
     this.outdecoder = outdecoder;
     this.typeseeker = null;
 }