コード例 #1
0
                protected GenericValueAnalysis(string methodName,
                                               IMethodDriver <TExpr, TVar> methodDriver)
                {
                    ThresholdDB.Reset();
                    BoxedVariable <TVar> .ResetFreshVariableCounter();

                    //        method_name = methodName;
                    method_driver = methodDriver;

                    EvaluatorOfConstants = new ConstantEvaluator(ContextProvider,
                                                                 MetaDataProvider);
                }
コード例 #2
0
        public override Interval Widen(Interval that)
        {
            Interval result;

            if (this.TryTrivialJoin(that, out result))
            {
                return(result);
            }

            return(For(LowerBound <that.LowerBound
                                   ?ThresholdDB.GetPrevious(LowerBound)
                                       : that.LowerBound,
                                       UpperBound> that.UpperBound
                                            ? ThresholdDB.GetNext(UpperBound)
                                            : that.UpperBound));
        }
コード例 #3
0
                public override TDomain Assume(APC pc, EdgeTag tag, TVar condition, TDomain data)
                {
                    var boxed = ToBoxedExpression(pc, condition);

                    if (tag != EdgeTag.False)
                    {
                        bool value;
                        if (boxed.IsTrivialCondition(out value))
                        {
                            return(!value ? data.Bottom : data);
                        }
                    }

                    List <int> thresholds;

                    if (ThresholdDB.TryGetAThreshold(boxed, expression_decoder, out thresholds))
                    {
                        ThresholdDB.Add(thresholds);
                    }

                    TDomain result;

                    switch (tag)
                    {
                    case EdgeTag.True:
                    case EdgeTag.Requires:
                    case EdgeTag.Assume:
                    case EdgeTag.Invariant:
                        result = data.AssumeTrue(boxed);
                        break;

                    case EdgeTag.False:
                        result = data.AssumeFalse(boxed);
                        break;

                    default:
                        result = data;
                        break;
                    }

                    if (tag != EdgeTag.False)
                    {
                        var abstractType =
                            ContextProvider.ValueContext.GetType(
                                ContextProvider.MethodContext.CFG.Post(pc), condition);
                        if (abstractType.IsNormal() &&
                            MetaDataProvider.Equal(abstractType.Value,
                                                   MetaDataProvider.System_Boolean))
                        {
                            var guard =
                                BoxedExpression.Binary(BinaryOperator.Ceq, boxed,
                                                       BoxedExpression.Const(1,
                                                                             MetaDataProvider
                                                                             .
                                                                             System_Int32));

                            result = result.AssumeTrue(guard);
                        }
                    }

                    return(result);
                }