public SimpleObjectInvariantDispatcher( IMethodDriver <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, Expression, Variable, LogOptions> mdriver, IOutputResults output, bool allowDisjunctivePreconditions) : base(mdriver, output, allowDisjunctivePreconditions) { Contract.Requires(mdriver != null); Contract.Requires(output != null); this.objectInvariants = new InferenceDB(exp => exp.Simplify(mdriver.MetaDataDecoder), exp => true); }
/// <param name="extraFilter"> extraFilter(e) == true if e should not be suggested</param> public SimplePreconditionDispatcher( IMethodDriver <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, Expression, Variable, LogOptions> mdriver, IOutputResults output, bool allowDisjunctivePreconditions, Func <BoxedExpression, bool> extraFilter = null) : base(mdriver, output, allowDisjunctivePreconditions) { Contract.Requires(mdriver != null); Contract.Requires(output != null); this.preconditions = new InferenceDB(exp => exp.Simplify(mdriver.MetaDataDecoder), this.IsSuitableInRequires); this.shouldFilter = extraFilter; }
public SimpleAssumeDispatcher( IMethodDriver <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, Expression, Variable, LogOptions> mdriver, IOutputResults output, bool allowDisjunctivePreconditions, bool aggressiveInference) : base(mdriver, output, allowDisjunctivePreconditions) { Contract.Requires(mdriver != null); Contract.Requires(output != null); this.entryAssumptions = new InferenceDB(exp => exp.Simplify(mdriver.MetaDataDecoder), _ => true); this.calleeAssumptions = new Dictionary <Method, InferenceDB>(); this.calleeAssumptionsPCs = new Dictionary <Method, List <APC> >(); this.AggressiveInferece = aggressiveInference; }
protected ProofOutcome GenericAddPreconditions(ProofObligation obl, IEnumerable <BoxedExpression> preconditions, ProofOutcome originalOutcome, InferenceDB preconditionDB, PreconditionChecker checkPrecondition) { var outcome = originalOutcome; foreach (var pre in preconditions) { if (pre == null) { continue; } // 1. Simplify the expression var simplified = SimplifyAndFix(obl.PCForValidation, pre); if (simplified == null) { continue; } if (DisjunctivePreconditionsAreDisallowed(simplified)) { continue; } // 2. Have we already seen this precondition? if (preconditionDB.TryLookUp(obl, simplified, out outcome)) { continue; } else { outcome = originalOutcome; } // 3. See if it is valid if (checkPrecondition(simplified, outcome, out outcome)) { preconditionDB.Add(obl, simplified, outcome); } } return(outcome); }
public IEnumerable <WarningContext> AddCalleeAssumes(ProofObligation obl, IEnumerable <IInferredCondition> calleeAssumes) { var md = this.mdriver; var result = new List <WarningContext>(); foreach (var calleeAssume in calleeAssumes.OfType <InferredCalleeCondition <Method> >()) { InferenceDB db; if (!this.calleeAssumptions.TryGetValue(calleeAssume.Callee, out db)) { var calleeWarningContext = GetContextForCallee(calleeAssume.Callee); db = new InferenceDB(exp => exp.Simplify(md.MetaDataDecoder), _ => true, calleeWarningContext); this.calleeAssumptions.Add(calleeAssume.Callee, db); this.calleeAssumptionsPCs.Add(calleeAssume.Callee, new List <APC>()); // add the entry to the map calleAssumptions --> PC // Get the witnesses for the scoring result.Add(new WarningContext(WarningContext.ContextType.InferredCalleeAssume, (int)calleeWarningContext)); if (calleeAssume.Expr.IsBinary && calleeAssume.Expr.BinaryOp == BinaryOperator.LogicalOr) { result.Add(new WarningContext(WarningContext.ContextType.InferredCalleeAssumeContainsDisjunction, /*unused?*/ 1)); } if (md.AnalysisDriver.MethodCache.GetWitnessForMayReturnNull(calleeAssume.Callee)) { result.Add(new WarningContext(WarningContext.ContextType.ViaMethodCallThatMayReturnNull, /*unused?*/ 1)); } } base.GenericAddPreconditions(obl, new[] { calleeAssume.Expr }, ProofOutcome.Top, db, this.True); this.calleeAssumptionsPCs[calleeAssume.Callee].Add(calleeAssume.CalleePC); } this.necessaryPostconditionCandidates = calleeAssumes.OfType <InferredCalleeNecessaryConditionCandidate <Method> >(); return(result.Distinct()); }