コード例 #1
0
    public bool TryInferConditions(ProofObligation obl, ICodeFixesManager codefixesManager, out InferredConditions preConditions)
    {
      preConditions = null;
      foreach (var inferencer in this.inferencers)
      {
        if (inferencer == null)
          continue;

        InferredConditions tmp;
        if (inferencer.TryInferConditions(obl, codefixesManager, out tmp))
        {
          Contract.Assert(tmp != null);
          if (preConditions == null)
          {
            preConditions = tmp;
          }
          else
          {
            preConditions.AddRange(tmp);
          }
        }
      }

      return preConditions != null;
    }
コード例 #2
0
        virtual public bool TryInferConditions(ProofObligation obl, ICodeFixesManager codefixesManager, out InferredConditions preConditions)
        {
            var preConds = PreconditionSuggestion.ExpressionsInPreState(obl.ConditionForPreconditionInference, this.MethodDriver.Context, this.MethodDriver.MetaDataDecoder, obl.PC, allowedKinds: ExpressionInPreStateKind.All);

            preConditions = /*preConds == null ? null : */ preConds.Where(pre => pre.hasVariables).AsInferredPreconditions(isSufficient: true);
            return /*preConditions != null && */ (preConditions.Any());
        }
コード例 #3
0
        public bool TryInferConditions(ProofObligation obl, ICodeFixesManager codefixesManager, out InferredConditions preConditions)
        {
            preConditions = null;
            foreach (var inferencer in this.inferencers)
            {
                if (inferencer == null)
                {
                    continue;
                }

                InferredConditions tmp;
                if (inferencer.TryInferConditions(obl, codefixesManager, out tmp))
                {
                    Contract.Assert(tmp != null);
                    if (preConditions == null)
                    {
                        preConditions = tmp;
                    }
                    else
                    {
                        preConditions.AddRange(tmp);
                    }
                }
            }

            return(preConditions != null);
        }
 public bool TryInferPrecondition(ProofObligation obl, ICodeFixesManager codefixesManager, out InferredPreconditions preConditions)
 {
     DateTime now = DateTime.Now;
       		bool flag = this.inner.TryInferPrecondition(obl, codefixesManager, out preConditions);
       		PreconditionInferenceProfiler.inferenceTime += DateTime.Now - now;
       	if (preConditions == null)
         return false;
       	if (flag)
         PreconditionInferenceProfiler.inferred += Enumerable.Count<IInferredPrecond>((IEnumerable<IInferredPrecond>) preConditions);
       	return flag;
 }
コード例 #5
0
        public override bool TryInferConditions(ProofObligation obl, ICodeFixesManager codefixesManager, out InferredConditions preConditions)
        {
            // First we try to read exp in the prestate

            if (base.TryInferConditions(obl, codefixesManager, out preConditions))
            {
                // if we succeed, now we should prove it is a precondition according to Sect. 4 of [CCL-VMCAI11]
                var necessarypreConditions = preConditions.Where(pre => new PreconditionCheckedAllOverThePathsAnalysis(this.obligations, this.MethodDriver).CheckPreconditionAdmissibility(pre.Expr)).AsInferredPreconditions();
                obl.NotifySufficientYetNotNecessaryPreconditions(preConditions.Except(necessarypreConditions));

                preConditions = necessarypreConditions;
                return(necessarypreConditions.Any());
            }

            return(false);
        }
 public bool TryInferPrecondition(ProofObligation obl, ICodeFixesManager codefixesManager, out InferredPreconditions preConditions)
 {
     preConditions = (InferredPreconditions) null;
     foreach (IPreconditionInference preconditionInference in this.inferencers)
     {
         InferredPreconditions preConditions1;
         if (preconditionInference != null && preconditionInference.TryInferPrecondition(obl, codefixesManager, out preConditions1))
         {
             if (preConditions == null)
                 preConditions = preConditions1;
      			else
             preConditions.AddRange((IEnumerable<IInferredPrecond>) preConditions1);
         }
     }
     return preConditions != null;
 }
コード例 #7
0
        public ContractInferenceManager(bool CanAddPreconditions, IOverriddenMethodPreconditionsDispatcher overriddenMethodPreconditionsDispatcher, PreconditionInferenceManager precondition, IObjectInvariantDispatcher invariants, IPostconditionDispatcher postcondition, IAssumeDispatcher assumptions, ICodeFixesManager codefixesManager, IOutput output)
        {
            Contract.Requires(overriddenMethodPreconditionsDispatcher != null);
            Contract.Requires(precondition != null);
            Contract.Requires(invariants != null);
            Contract.Requires(postcondition != null);
            Contract.Requires(assumptions != null);
            Contract.Requires(codefixesManager != null);
            Contract.Requires(output != null);

            this.CanAddPreconditions = CanAddPreconditions;
            this.OverriddenMethodPreconditionDispatcher = overriddenMethodPreconditionsDispatcher;
            this.PreCondition     = precondition;
            this.ObjectInvariant  = invariants;
            this.PostCondition    = postcondition;
            this.Assumptions      = assumptions;
            this.CodeFixesManager = codefixesManager;
            this.Output           = output;
        }
コード例 #8
0
        public ContractInferenceManager(bool CanAddPreconditions, IOverriddenMethodPreconditionsDispatcher overriddenMethodPreconditionsDispatcher, PreconditionInferenceManager precondition, IObjectInvariantDispatcher invariants, IPostconditionDispatcher postcondition, IAssumeDispatcher assumptions, ICodeFixesManager codefixesManager, IOutput output)
        {
            Contract.Requires(overriddenMethodPreconditionsDispatcher != null);
            Contract.Requires(precondition != null);
            Contract.Requires(invariants != null);
            Contract.Requires(postcondition != null);
            Contract.Requires(assumptions != null);
            Contract.Requires(codefixesManager != null);
            Contract.Requires(output != null);

            this.CanAddPreconditions = CanAddPreconditions;
            this.OverriddenMethodPreconditionDispatcher = overriddenMethodPreconditionsDispatcher;
            this.PreCondition = precondition;
            this.ObjectInvariant = invariants;
            this.PostCondition = postcondition;
            this.Assumptions = assumptions;
            this.CodeFixesManager = codefixesManager;
            this.Output = output;
        }
コード例 #9
0
        public bool TryInferConditions(ProofObligation obl, ICodeFixesManager codefixesManager, out InferredConditions preConditions)
        {
            var watch = new Stopwatch();

            watch.Start();
            var result = inner.TryInferConditions(obl, codefixesManager, out preConditions);

            watch.Stop();

            inferenceTime += watch.Elapsed;

            if (preConditions == null)
            {
                return(false);
            }

            if (result)
            {
                inferred += preConditions.Count();
            }

            return(result);
        }
コード例 #10
0
 public bool TryInferConditions(ProofObligation obl, ICodeFixesManager codefixesManager, out InferredConditions preConditions)
 {
     preConditions = null;
     return(false);
 }
コード例 #11
0
 public CodeFixesProfiler(ICodeFixesManager inner, bool trace)
 {
     Contract.Requires(inner != null);
     this.inner = inner;
     this.trace = trace;
 }
コード例 #12
0
 public bool TryInferPrecondition(ProofObligation obl, ICodeFixesManager codefixesManager, out InferredPreconditions preConditions)
 {
     preConditions = (InferredPreconditions)null;
     return false;
 }